From: Douglas Bagnall Date: Wed, 19 Feb 2025 02:44:34 +0000 (+1300) Subject: ndr:dns: introduce and use MAX_COMP_LEN X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9032bb499194ef45ef80f131803bd7b163b781f0;p=thirdparty%2Fsamba.git ndr:dns: introduce and use MAX_COMP_LEN it means 63 or 0x3f, and is the maximum length of a DNS/NBT component. We also simplify an error message that was fond of long hex representations of small numbers. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14378 Signed-off-by: Douglas Bagnall Reviewed-by: Andreas Schneider --- diff --git a/librpc/ndr/ndr_dns_utils.c b/librpc/ndr/ndr_dns_utils.c index 9b603b364f1..68d7800173e 100644 --- a/librpc/ndr/ndr_dns_utils.c +++ b/librpc/ndr/ndr_dns_utils.c @@ -7,7 +7,7 @@ plenty. */ #define MAX_COMPONENTS 128 - +#define MAX_COMP_LEN 63 /* @@ -87,7 +87,7 @@ static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr, err_name, (len &0xC)); } if (*offset + len + 1 > ndr->data_size || - len > 63 /* impossible!, but we live in fear */ ) { + len > MAX_COMP_LEN /* impossible!, but we live in fear */ ) { return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD %s NAME component, "\ "length too long", @@ -272,12 +272,11 @@ enum ndr_err_code ndr_push_dns_string_list(struct ndr_push *ndr, complen = strcspn(s, "."); /* the length must fit into 6 bits (i.e. <= 63) */ - if (complen > 0x3F) { + if (complen > MAX_COMP_LEN) { return ndr_push_error(ndr, NDR_ERR_STRING, - "component length %zu[%08zX] > " \ - "0x0000003F", + "component length %zu > %u", complen, - complen); + MAX_COMP_LEN); } if (complen == 0 && s[complen] == '.') {