From: Douglas Bagnall Date: Thu, 14 Nov 2019 00:14:08 +0000 (+1300) Subject: ndrdump: correctly find the public strict by number X-Git-Tag: talloc-2.3.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bb642d98e1c26064907f8f671c1de864f2d8c2f;p=thirdparty%2Fsamba.git ndrdump: correctly find the public strict by number We were finding a function that happened to have the same ordinal number. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191 Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index 4173f03098d..4f812eeda7a 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -66,6 +66,7 @@ static const struct ndr_interface_call *find_struct( struct ndr_interface_call *out_buffer) { unsigned int i; + const struct ndr_interface_public_struct *public_struct = NULL; if (isdigit(struct_name[0])) { char *eptr = NULL; i = strtoul(struct_name, &eptr, 0); @@ -76,23 +77,25 @@ static const struct ndr_interface_call *find_struct( struct_name); exit(1); } - return &p->calls[i]; - } - for (i=0;inum_public_structs;i++) { - if (strcmp(p->public_structs[i].name, struct_name) == 0) { - break; + public_struct = &p->public_structs[i]; + } else { + for (i=0;inum_public_structs;i++) { + if (strcmp(p->public_structs[i].name, struct_name) == 0) { + break; + } } - } - if (i == p->num_public_structs) { - printf("Public structure '%s' not found\n", struct_name); - exit(1); + if (i == p->num_public_structs) { + printf("Public structure '%s' not found\n", struct_name); + exit(1); + } + public_struct = &p->public_structs[i]; } *out_buffer = (struct ndr_interface_call) { - .name = p->public_structs[i].name, - .struct_size = p->public_structs[i].struct_size, - .ndr_pull = p->public_structs[i].ndr_pull, - .ndr_push = p->public_structs[i].ndr_push, - .ndr_print = p->public_structs[i].ndr_print + .name = public_struct->name, + .struct_size = public_struct->struct_size, + .ndr_pull = public_struct->ndr_pull, + .ndr_push = public_struct->ndr_push, + .ndr_print = public_struct->ndr_print }; return out_buffer; }