svn commit: samba r3073 - in branches/SAMBA_4_0/source: lib librpc/ndr

abartlet at samba.org abartlet at samba.org
Wed Oct 20 02:02:04 GMT 2004


Author: abartlet
Date: 2004-10-20 02:02:00 +0000 (Wed, 20 Oct 2004)
New Revision: 3073

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=3073&nolog=1

Log:
Fix bug in the handling of null-terminated ASCII strings in RPC.

Because we didn't count the null terminator, we would not move past it
in the packet.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/lib/util_str.c
   branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/util_str.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_str.c	2004-10-19 23:41:26 UTC (rev 3072)
+++ branches/SAMBA_4_0/source/lib/util_str.c	2004-10-20 02:02:00 UTC (rev 3073)
@@ -1120,6 +1120,24 @@
 
 
 /*******************************************************************
+return the number of bytes occupied by a buffer in ASCII format
+the result includes the null termination
+limited by 'n' bytes
+********************************************************************/
+size_t ascii_len_n(const char *src, size_t n)
+{
+	size_t len;
+
+	len = strnlen(src, n);
+	if (len+1 <= n) {
+		len += 1;
+	}
+
+	return len;
+}
+
+
+/*******************************************************************
  Return a string representing a CIFS attribute for a file.
 ********************************************************************/
 char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)

Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c	2004-10-19 23:41:26 UTC (rev 3072)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr_basic.c	2004-10-20 02:02:00 UTC (rev 3073)
@@ -657,7 +657,7 @@
 
 	case LIBNDR_FLAG_STR_NULLTERM:
 		if (byte_mul == 1) {
-			len1 = strnlen(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
+			len1 = ascii_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
 		} else {
 			len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
 		}



More information about the samba-cvs mailing list