svn commit: samba r19192 - in branches/SAMBA_3_0/source/lib/ldb/ldb_ldap: .

metze at samba.org metze at samba.org
Mon Oct 9 08:26:59 GMT 2006


Author: metze
Date: 2006-10-09 08:26:58 +0000 (Mon, 09 Oct 2006)
New Revision: 19192

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

Log:
merge from samba4:

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!

metze
Modified:
   branches/SAMBA_3_0/source/lib/ldb/ldb_ldap/ldb_ldap.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/ldb/ldb_ldap/ldb_ldap.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/ldb_ldap/ldb_ldap.c	2006-10-09 08:25:27 UTC (rev 19191)
+++ branches/SAMBA_3_0/source/lib/ldb/ldb_ldap/ldb_ldap.c	2006-10-09 08:26:58 UTC (rev 19192)
@@ -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