svn commit: samba r19009 - in branches/SAMBA_4_0/source/lib/ldb/ldb_ldap: .

tridge at samba.org tridge at samba.org
Sat Sep 30 07:54:21 GMT 2006


Author: tridge
Date: 2006-09-30 07:54:20 +0000 (Sat, 30 Sep 2006)
New Revision: 19009

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

Log:

ensure that data values from ldap libs are null terminated, to allow
ldb_msg_find_attr_as_string() to work correctly.

Thanks to Jim Myers for spotting this!

Modified:
   branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c	2006-09-29 21:26:33 UTC (rev 19008)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c	2006-09-30 07:54:20 UTC (rev 19009)
@@ -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++;
 	}



More information about the samba-cvs mailing list