diff options
author | Ralph Boehme <slow@samba.org> | 2016-05-17 12:30:46 +0200 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2016-06-16 00:06:27 +0200 |
commit | df079962ef708de96e54ded13da04b6e12ac00d0 (patch) | |
tree | cff0e79ee747a1a555837e19b7c5a40aac2c42e5 /librpc/ndr | |
parent | 234a470f198f8f09f46aaeaf58f966faccedef18 (diff) | |
download | samba-df079962ef708de96e54ded13da04b6e12ac00d0.tar.gz |
librpc/ndr: add flag LIBNDR_FLAG_NO_COMPRESSION
This flag can be used to change marshalling behaviour with regard to
compression.
Example: DNS packets make use of so called DNS name compression which
means that for identical strings in a DNS packet, the second string is
replaced with a reference (an offset) to the first.
Setting this flag requests to turns off the marshalling compression.
This will be used in the next commit to prevent name compression in DNS
TSIG records.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11520
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'librpc/ndr')
-rw-r--r-- | librpc/ndr/libndr.h | 3 | ||||
-rw-r--r-- | librpc/ndr/ndr_dns.c | 50 |
2 files changed, 30 insertions, 23 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 10054376eec..6034229336e 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -125,6 +125,9 @@ struct ndr_print { #define LIBNDR_FLAG_STR_RAW8 (1<<13) #define LIBNDR_STRING_FLAGS (0x7FFC) +/* Disable string token compression */ +#define LIBNDR_FLAG_NO_COMPRESSION (1<<15) + /* * don't debug NDR_ERR_BUFSIZE failures, * as the available buffer might be incomplete. diff --git a/librpc/ndr/ndr_dns.c b/librpc/ndr/ndr_dns.c index ab0c83a7e84..fcc1315f8e0 100644 --- a/librpc/ndr/ndr_dns.c +++ b/librpc/ndr/ndr_dns.c @@ -169,28 +169,30 @@ _PUBLIC_ enum ndr_err_code ndr_push_dns_string(struct ndr_push *ndr, size_t complen; uint32_t offset; - /* see if we have pushed the remaining string already, - * if so we use a label pointer to this string - */ - ndr_err = ndr_token_retrieve_cmp_fn(&ndr->dns_string_list, s, - &offset, - (comparison_fn_t)strcmp, - false); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - uint8_t b[2]; - - if (offset > 0x3FFF) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "offset for dns string " \ - "label pointer " \ - "%u[%08X] > 0x00003FFF", - offset, offset); + if (!(ndr->flags & LIBNDR_FLAG_NO_COMPRESSION)) { + /* see if we have pushed the remaining string already, + * if so we use a label pointer to this string + */ + ndr_err = ndr_token_retrieve_cmp_fn(&ndr->dns_string_list, s, + &offset, + (comparison_fn_t)strcmp, + false); + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + uint8_t b[2]; + + if (offset > 0x3FFF) { + return ndr_push_error(ndr, NDR_ERR_STRING, + "offset for dns string " \ + "label pointer " \ + "%u[%08X] > 0x00003FFF", + offset, offset); + } + + b[0] = 0xC0 | (offset>>8); + b[1] = (offset & 0xFF); + + return ndr_push_bytes(ndr, b, 2); } - - b[0] = 0xC0 | (offset>>8); - b[1] = (offset & 0xFF); - - return ndr_push_bytes(ndr, b, 2); } complen = strcspn(s, "."); @@ -213,8 +215,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_dns_string(struct ndr_push *ndr, /* remember the current componemt + the rest of the string * so it can be reused later */ - NDR_CHECK(ndr_token_store(ndr, &ndr->dns_string_list, s, - ndr->offset)); + if (!(ndr->flags & LIBNDR_FLAG_NO_COMPRESSION)) { + NDR_CHECK(ndr_token_store(ndr, &ndr->dns_string_list, s, + ndr->offset)); + } /* push just this component into the blob */ NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, |