]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/lber-int.h
check for overflows
[openldap] / libraries / liblber / lber-int.h
index 7686cd57d90344b056aedda0547823f04e30c8e5..fde8bc5470a1454c1986c0b88779474a24aa6a34 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,30 +38,27 @@ typedef void (*BER_LOG_FN)(FILE *file,
 
 LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
 
+#ifdef LDAP_MEMORY_TRACE
+# ifndef LDAP_MEMORY_DEBUG
+#  define LDAP_MEMORY_DEBUG 1
+# endif
+#endif
+
+#ifdef LDAP_MEMORY_DEBUG
+LBER_V (long)  ber_int_meminuse;
+#endif
+#if defined(LDAP_MEMORY_DEBUG) && ((LDAP_MEMORY_DEBUG +0) & 2)
+# define LDAP_MEMORY_DEBUG_ASSERT assert
+#else
+# define LDAP_MEMORY_DEBUG_ASSERT(expr) ((void) 0)
+#endif
+
 struct lber_options {
        short lbo_valid;
        unsigned short          lbo_options;
        int                     lbo_debug;
-       long            lbo_meminuse;
 };
 
-#ifdef NEW_LOGGING
-/*
-#    ifdef LDAP_DEBUG
-#        ifdef LDAP_LOG
-#            undef LDAP_LOG
-#        endif
-#        define LDAP_LOG(a) ber_pvt_log_output a
- */
-#        define BER_DUMP(a) ber_output_dump a
-/*
-#    else
-#        define LDAP_LOG(a)
-#        define BER_DUMP(a)
-#    endif
- */
-#endif
-
 LBER_F( int ) ber_pvt_log_output(
        const char *subsystem,
        int level,
@@ -107,9 +104,13 @@ struct sockbuf {
 #define        sb_options              sb_opts.lbo_options
 #define        sb_debug                sb_opts.lbo_debug
        ber_socket_t            sb_fd;
+       ber_len_t                       sb_max_incoming;
        unsigned int            sb_trans_needs_read:1;
        unsigned int            sb_trans_needs_write:1;
-       ber_len_t                       sb_max_incoming;
+#ifdef LDAP_PF_LOCAL_SENDMSG
+       char                            sb_ungetlen;
+       char                            sb_ungetbuf[8];
+#endif
 };
 
 #define SOCKBUF_VALID( sb )    ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
@@ -124,6 +125,14 @@ struct seqorset {
 };
 
 
+/*
+ * decode.c, encode.c
+ */
+
+/* Simplest OID max-DER-component to implement in both decode and encode */
+#define LBER_OID_COMPONENT_MAX ((unsigned long)-1 - 128)
+
+
 /*
  * io.c
  */
@@ -142,15 +151,6 @@ LBER_F (void) ber_rewind LDAP_P(( BerElement * ));
  */
 #define ber_log_printf ber_pvt_log_printf
 
-#ifdef NEW_LOGGING
-LBER_F( int )
-ber_output_dump LDAP_P((
-       const char *subsys,
-       int level,
-       BerElement *ber,
-       int inout ));
-#endif
-
 LBER_F( int )
 ber_log_bprint LDAP_P((
        int errlvl,