]> git.sur5r.net Git - openldap/commitdiff
ITS#6733
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 16:56:20 +0000 (16:56 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 16:56:20 +0000 (16:56 +0000)
CHANGES
libraries/liblber/memory.c

diff --git a/CHANGES b/CHANGES
index 3d76add8e2991a2b1e2c6937c313a0cd66b2fd12..f9283e2b869ec42a529208016619b62c76efc728 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,7 @@ OpenLDAP 2.4.24 Engineering
        Added slapd-sql support for long long keys (ITS#6617)
        Fixed liblber to not close invalid sockets (ITS#6585)
        Fixed liblber error setting (ITS#6732)
+       Fixed liblber memory debugging (ITS#6733)
        Fixed libldap dnssrv port format specifier (ITS#6644)
        Fixed libldap EOF handling (ITS#6723)
        Fixed libldap GnuTLS hang on socket close (ITS#6673)
index 8712031dc54e2d99f46062e5e775c576bf99c41b..ae063c99d19d20c63fae9b91b76962a8e95df930 100644 (file)
@@ -62,9 +62,9 @@ struct ber_mem_hdr {
 };
 
 /* Pattern at top of allocated space */
-#define LBER_MEM_JUNK 0xdeaddadaU
+#define LBER_MEM_JUNK ((ber_int_t) 0xdeaddada)
 
-static const struct ber_mem_hdr ber_int_mem_hdr = { LBER_MEM_JUNK, 0, 0 };
+static const struct ber_mem_hdr ber_int_mem_hdr = { LBER_MEM_JUNK };
 
 /* Note sequence and ber_int_meminuse are counters, but are not
  * thread safe.  If you want to use these values for multithreaded applications,
@@ -256,7 +256,9 @@ ber_memcalloc_x( ber_len_t n, ber_len_t s, void *ctx )
 
        if( ber_int_memory_fns == NULL || ctx == NULL ) {
 #ifdef LDAP_MEMORY_DEBUG
-               new = calloc(1, n*s + sizeof(struct ber_mem_hdr) + sizeof(ber_int_t));
+               new = n < (-sizeof(struct ber_mem_hdr) - sizeof(ber_int_t)) / s
+                       ? calloc(1, n*s + sizeof(struct ber_mem_hdr) + sizeof(ber_int_t))
+                       : NULL;
                if( new )
                {
                struct ber_mem_hdr *mh = new;