svn commit: samba r7749 - in branches/SAMBA_4_0/source: ldap_server lib/ldb/ldb_ildap libcli/ldap libcli/util

tridge at samba.org tridge at samba.org
Sun Jun 19 10:37:45 GMT 2005


Author: tridge
Date: 2005-06-19 10:37:45 +0000 (Sun, 19 Jun 2005)
New Revision: 7749

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

Log:
some bug fixes from testing with socket:testnonblock

- fixed some infinite loops in asn1.c

- ensure asn1 callers know if an error is end of buffer or bad data

- handle npending 0 in ldap server

Modified:
   branches/SAMBA_4_0/source/ldap_server/ldap_server.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
   branches/SAMBA_4_0/source/libcli/ldap/ldap.c
   branches/SAMBA_4_0/source/libcli/util/asn1.c


Changeset:
Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.c
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2005-06-19 09:35:02 UTC (rev 7748)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2005-06-19 10:37:45 UTC (rev 7749)
@@ -254,10 +254,10 @@
 		return;
 	}
 	if (npending == 0) {
+		ldapsrv_terminate_connection(conn, "EOF from client");
 		return;
 	}
 
-
 	conn->partial.data = talloc_realloc_size(conn, conn->partial.data, 
 						 conn->partial.length + npending);
 	if (conn->partial.data == NULL) {

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2005-06-19 09:35:02 UTC (rev 7748)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2005-06-19 10:37:45 UTC (rev 7749)
@@ -124,6 +124,8 @@
 		if (ildb->rootDSE != NULL) {
 			base = ldb_msg_find_string(ildb->rootDSE, 
 						   "defaultNamingContext", "");
+		} else {
+			base = "";
 		}
 	}
 

Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap.c	2005-06-19 09:35:02 UTC (rev 7748)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap.c	2005-06-19 10:37:45 UTC (rev 7749)
@@ -501,7 +501,9 @@
 
 		ret->operation = LDB_OP_NOT;
 		ret->u.not.child = ldap_decode_filter_tree(ret, data);
-
+		if (ret->u.not.child == NULL) {
+			goto failed;
+		}
 		if (!asn1_end_tag(data)) {
 			goto failed;
 		}
@@ -595,7 +597,6 @@
 
 failed:
 	talloc_free(ret);
-	DEBUG(0,("Failed to parse ASN.1 LDAP filter\n"));
 	return NULL;	
 }
 

Modified: branches/SAMBA_4_0/source/libcli/util/asn1.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/util/asn1.c	2005-06-19 09:35:02 UTC (rev 7748)
+++ branches/SAMBA_4_0/source/libcli/util/asn1.c	2005-06-19 10:37:45 UTC (rev 7749)
@@ -299,8 +299,12 @@
 	if (len < 0 || data->ofs + len < data->ofs || data->ofs + len < len)
 		return False;
 
-	if (data->ofs + len > data->length)
+	if (data->ofs + len > data->length) {
+		/* we need to mark the buffer as consumed, so the caller knows
+		   this was an out of data error, and not a decode error */
+		data->ofs = data->length;
 		return False;
+	}
 
 	memcpy(p, data->data + data->ofs, len);
 	return True;
@@ -437,7 +441,7 @@
 		do {
 			asn1_read_uint8(data, &b);
 			v = (v<<7) | (b&0x7f);
-		} while (!data->has_error && b & 0x80);
+		} while (!data->has_error && (b & 0x80));
 		tmp_oid = talloc_asprintf_append(tmp_oid, " %u",  v);
 	}
 
@@ -540,7 +544,7 @@
 	uint8_t b;
 	*i = 0;
 
-	while (asn1_tag_remaining(data)>0) {
+	while (!data->has_error && asn1_tag_remaining(data)>0) {
 		if (!asn1_read_uint8(data, &b)) return False;
 		*i = (*i << 8) + b;
 	}
@@ -564,7 +568,7 @@
 	*v = 0;
 	
 	if (!asn1_start_tag(data, ASN1_ENUMERATED)) return False;
-	while (asn1_tag_remaining(data)>0) {
+	while (!data->has_error && asn1_tag_remaining(data)>0) {
 		uint8_t b;
 		asn1_read_uint8(data, &b);
 		*v = (*v << 8) + b;



More information about the samba-cvs mailing list