Author: abartlet
Date: 2006-10-06 03:40:45 +0000 (Fri, 06 Oct 2006)
New Revision: 19109

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19109

Log:
Merge fixes to ldb made since the TP3 release snapshot was taken.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_dn.c
   branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_utf8.c
   branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_ldap/ldb_ldap.c
   branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_tdb/ldb_cache.c


Changeset:
Modified: branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_dn.c
===================================================================
--- branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_dn.c   2006-10-06 
03:39:00 UTC (rev 19108)
+++ branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_dn.c   2006-10-06 
03:40:45 UTC (rev 19109)
@@ -345,6 +345,10 @@
 
        /* Allocate a structure to hold the exploded DN */
        edn = ldb_dn_new(mem_ctx);
+       if (edn == NULL) {
+               return NULL;
+       }
+
        pdn = NULL;
 
        /* Empty DNs */
@@ -670,6 +674,7 @@
        dst.name = talloc_strdup(mem_ctx, src->name);
        if (dst.name == NULL) {
                talloc_free(dst.value.data);
+               dst.value.data = NULL;
        }
 
        return dst;
@@ -693,6 +698,7 @@
        newdn->comp_num = num_el;
        n = newdn->comp_num - 1;
        newdn->components = talloc_array(newdn, struct ldb_dn_component, 
newdn->comp_num);
+       if (newdn->components == NULL) goto failed;
 
        if (dn->comp_num == 0) return newdn;
        e = dn->comp_num - 1;
@@ -813,6 +819,7 @@
                int comp_num = dn2->comp_num;
                if (dn1 != NULL) comp_num += dn1->comp_num;
                newdn = ldb_dn_copy_partial(mem_ctx, dn2, comp_num);
+               LDB_DN_NULL_FAILED(newdn);
        }
 
        if (dn1 == NULL) {
@@ -822,6 +829,9 @@
        for (i = 0; i < dn1->comp_num; i++) {
                newdn->components[i] = ldb_dn_copy_component(newdn->components,
                                                           
&(dn1->components[i]));
+               if (newdn->components[i].value.data == NULL) {
+                       goto failed;
+               }
        }
 
        return newdn;

Modified: branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_utf8.c
===================================================================
--- branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_utf8.c 2006-10-06 
03:39:00 UTC (rev 19108)
+++ branches/SAMBA_4_0_RELEASE/source/lib/ldb/common/ldb_utf8.c 2006-10-06 
03:40:45 UTC (rev 19109)
@@ -126,7 +126,7 @@
 {
        int i;
        char *ret = talloc_strdup(mem_ctx, s);
-       if (!s) {
+       if (!ret) {
                errno = ENOMEM;
                return NULL;
        }

Modified: branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_ldap/ldb_ldap.c
===================================================================
--- branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_ldap/ldb_ldap.c       
2006-10-06 03:39:00 UTC (rev 19108)
+++ branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_ldap/ldb_ldap.c       
2006-10-06 03:40:45 UTC (rev 19109)
@@ -210,10 +210,15 @@
        }
 
        for (i=0;i<count;i++) {
-               el->values[i].data = talloc_memdup(el->values, bval[i]->bv_val, 
bval[i]->bv_len);
+               /* we have to ensure this is null terminated so that
+                  ldb_msg_find_attr_as_string() can work */
+               el->values[i].data = talloc_size(el->values, bval[i]->bv_len+1);
                if (!el->values[i].data) {
+                       errno = ENOMEM;
                        return -1;
                }
+               memcpy(el->values[i].data, bval[i]->bv_val, bval[i]->bv_len);
+               el->values[i].data[bval[i]->bv_len] = 0;
                el->values[i].length = bval[i]->bv_len;
                el->num_values++;
        }

Modified: branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_tdb/ldb_cache.c
===================================================================
--- branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_tdb/ldb_cache.c       
2006-10-06 03:39:00 UTC (rev 19108)
+++ branches/SAMBA_4_0_RELEASE/source/lib/ldb/ldb_tdb/ldb_cache.c       
2006-10-06 03:40:45 UTC (rev 19109)
@@ -318,7 +318,7 @@
        struct ltdb_private *ltdb = module->private_data;
        struct ldb_dn *baseinfo_dn = NULL;
        struct ldb_dn *indexlist_dn = NULL;
-       double seq;
+       uint64_t seq;
 
        if (ltdb->cache == NULL) {
                ltdb->cache = talloc_zero(ltdb, struct ltdb_cache);
@@ -356,7 +356,7 @@
 
        /* if the current internal sequence number is the same as the one
           in the database then assume the rest of the cache is OK */
-       seq = ldb_msg_find_attr_as_double(ltdb->cache->baseinfo, 
LTDB_SEQUENCE_NUMBER, 0);
+       seq = ldb_msg_find_attr_as_uint64(ltdb->cache->baseinfo, 
LTDB_SEQUENCE_NUMBER, 0);
        if (seq == ltdb->sequence_number) {
                goto done;
        }

Reply via email to