[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Mon Dec 20 19:27:01 MST 2010


The branch, master has been updated
       via  4820c97 dns: fixed the padding for dnsp_name fields in LDAP
       via  049a16c dns: auto-calculate the wDataLength field in DNS records
       via  8c04657 s4-dns: fixed a crash bug in dlz_bind9 code
       via  b9a2852 dnsp: fixed parsing of dns_name structures
      from  8998f4b Added call out to a Linux-compatible fallocate() when we need to extend a file allocation extent without changing end-of-file size.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4820c97e9ea00e73f3188f9834a03913ed74df80
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Dec 21 11:59:54 2010 +1100

    dns: fixed the padding for dnsp_name fields in LDAP
    
    all names are NUL terminated, but may have additional padding as well
    
    Autobuild-User: Andrew Tridgell <tridge at samba.org>
    Autobuild-Date: Tue Dec 21 03:26:26 CET 2010 on sn-devel-104

commit 049a16c8ef475f6b327292d231022fd4c5aaddf1
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Dec 21 11:59:05 2010 +1100

    dns: auto-calculate the wDataLength field in DNS records
    
    we need this for creating new records

commit 8c04657600cd6702dbfc66744fe2268c59ebea0b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Dec 21 11:57:50 2010 +1100

    s4-dns: fixed a crash bug in dlz_bind9 code
    
    we need to keep el_ctx for the next part of the loop

commit b9a2852fdd68a0691ff567557824be44bb08b27a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Dec 15 23:52:32 2010 +1100

    dnsp: fixed parsing of dns_name structures
    
    its not a pad byte, its a trailing zero

-----------------------------------------------------------------------

Summary of changes:
 librpc/idl/dnsp.idl            |    4 ++--
 librpc/ndr/ndr_dnsp.c          |   25 ++++++++++++++++++++-----
 source4/dns_server/dlz_bind9.c |    2 --
 3 files changed, 22 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/idl/dnsp.idl b/librpc/idl/dnsp.idl
index 905e420..eed0c47 100644
--- a/librpc/idl/dnsp.idl
+++ b/librpc/idl/dnsp.idl
@@ -92,7 +92,7 @@ interface dnsp
 		dnsp_name       nameTarget;
 	} dnsp_srv;
 
-	typedef [nodiscriminant] union {
+	typedef [nodiscriminant,gensize] union {
 		[case(DNS_TYPE_A)] [flag(NDR_BIG_ENDIAN)]   ipv4address ipv4;
 		[case(DNS_TYPE_NS)]                         dnsp_name ns;
 		[case(DNS_TYPE_CNAME)]                      dnsp_name cname;
@@ -109,7 +109,7 @@ interface dnsp
 	/* this is the format for the dnsRecord attribute in the DNS
 	   partitions in AD */
 	typedef [public] struct {
-		uint16          wDataLength;
+		[value(ndr_size_dnsRecordData(&data,wType,ndr->flags))] uint16 wDataLength;
 		dns_record_type wType;
 		uint32          dwFlags;
 		uint32          dwSerial;
diff --git a/librpc/ndr/ndr_dnsp.c b/librpc/ndr/ndr_dnsp.c
index 256638a..ae78425 100644
--- a/librpc/ndr/ndr_dnsp.c
+++ b/librpc/ndr/ndr_dnsp.c
@@ -36,14 +36,16 @@ _PUBLIC_ void ndr_print_dnsp_name(struct ndr_print *ndr, const char *name,
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_dnsp_name(struct ndr_pull *ndr, int ndr_flags, const char **name)
 {
-	uint8_t len, count;
+	uint8_t len, count, termination;
 	int i;
-	uint32_t total_len;
+	uint32_t total_len, raw_offset;
 	char *ret;
 
 	NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &len));
 	NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &count));
 
+	raw_offset = ndr->offset;
+
 	ret = talloc_strdup(ndr->current_mem_ctx, "");
 	if (!ret) {
 		return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp");
@@ -68,19 +70,32 @@ _PUBLIC_ enum ndr_err_code ndr_pull_dnsp_name(struct ndr_pull *ndr, int ndr_flag
 		ret[newlen-1] = 0;
 		total_len = newlen;
 	}
+	NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &termination));
+	if (termination != 0) {
+		return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp - not NUL terminated");
+	}
+	if (ndr->offset > raw_offset + len) {
+		return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp - overrun by %u bytes",
+				      ndr->offset - (raw_offset + len));
+	}
+	/* there could be additional pad bytes */
+	while (ndr->offset < raw_offset + len) {
+		uint8_t pad;
+		NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &pad));
+	}
 	(*name) = ret;
-	NDR_PULL_ALIGN(ndr, 2);
 	return NDR_ERR_SUCCESS;
 }
 
 enum ndr_err_code ndr_push_dnsp_name(struct ndr_push *ndr, int ndr_flags, const char *name)
 {
 	int count, total_len, i;
+
 	/* count the dots */
 	for (count=i=0; name[i]; i++) {
 		if (name[i] == '.') count++;
 	}
-	total_len = strlen(name) + 1;
+	total_len = strlen(name) + 1 + 1;
 	if (total_len > 255 || count > 255) {
 		return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
 				      "dns_name of length %d larger than 255", total_len);
@@ -94,7 +109,7 @@ enum ndr_err_code ndr_push_dnsp_name(struct ndr_push *ndr, int ndr_flags, const
 		NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)name, sublen));
 		name += sublen + 1;
 	}
-	NDR_PUSH_ALIGN(ndr, 2);
+	NDR_CHECK(ndr_push_uint8(ndr, ndr_flags, 0));
 
 	return NDR_ERR_SUCCESS;
 }
diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 7e18165..dc4c4bc 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -821,13 +821,11 @@ _PUBLIC_ isc_result_t dlz_allnodes(const char *zone, void *dbdata,
 			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 				state->log(ISC_LOG_ERROR, "samba_dlz: failed to parse dnsRecord for %s",
 					   ldb_dn_get_linearized(dn));
-				talloc_free(el_ctx);
 				continue;
 			}
 
 			result = b9_putnamedrr(state, allnodes, name, &rec);
 			if (result != ISC_R_SUCCESS) {
-				talloc_free(el_ctx);
 				continue;
 			}
 		}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list