From 732e8ab64d3c082dd142e4cbf07ebaec54549216 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Fri, 1 Feb 2013 17:44:16 +0100 Subject: [PATCH] ndrdump: make sure to deal with the highest relative pointer offset correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Guenther Signed-off-by: Günther Deschner Reviewed-by: Stefan Metzmacher --- librpc/tools/ndrdump.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index 91bf06fcd9a..4a102f52690 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -214,6 +214,7 @@ static NTSTATUS ndrdump_pull_and_print_pipes(const char *function, }; const struct ndr_interface_call_pipes *in_pipes = NULL; const struct ndr_interface_call_pipes *out_pipes = NULL; + uint32_t highest_ofs; ndr_table_init(); @@ -341,8 +342,14 @@ static NTSTATUS ndrdump_pull_and_print_pipes(const char *function, ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); - if (ndr_pull->offset != ndr_pull->data_size) { - printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - ndr_pull->offset); + if (ndr_pull->offset > ndr_pull->relative_highest_offset) { + highest_ofs = ndr_pull->offset; + } else { + highest_ofs = ndr_pull->relative_highest_offset; + } + + if (highest_ofs != ndr_pull->data_size) { + printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - highest_ofs); } if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -392,10 +399,16 @@ static NTSTATUS ndrdump_pull_and_print_pipes(const char *function, printf("pull returned %s\n", nt_errstr(status)); - if (ndr_pull->offset != ndr_pull->data_size) { - printf("WARNING! %d unread bytes\n", ndr_pull->data_size - ndr_pull->offset); - ndrdump_data(ndr_pull->data+ndr_pull->offset, - ndr_pull->data_size - ndr_pull->offset, + if (ndr_pull->offset > ndr_pull->relative_highest_offset) { + highest_ofs = ndr_pull->offset; + } else { + highest_ofs = ndr_pull->relative_highest_offset; + } + + if (highest_ofs != ndr_pull->data_size) { + printf("WARNING! %d unread bytes\n", ndr_pull->data_size - highest_ofs); + ndrdump_data(ndr_pull->data+highest_ofs, + ndr_pull->data_size - highest_ofs, dumpdata); } -- 2.11.4.GIT