summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-09-23 07:39:43 +0200
committerStefan Metzmacher <metze@samba.org>2013-09-24 00:11:07 +0200
commitc18c6c9fb53a84e587f5ed951e47a1bb5f53a30e (patch)
tree83d71585876c466daf9bb82b5e9ef631b2bb2b54 /librpc
parent3d3e8b53bf78c6ab442682b9fe22c902b9c45d73 (diff)
downloadsamba-c18c6c9fb53a84e587f5ed951e47a1bb5f53a30e.tar.gz
samba-c18c6c9fb53a84e587f5ed951e47a1bb5f53a30e.tar.bz2
samba-c18c6c9fb53a84e587f5ed951e47a1bb5f53a30e.zip
librpc/ndr: make use of ndr_dump_data() in ndr_print_array_uint8()
It's much easier to look at hexdump -C style output than a few thousand lines with 1 byte each. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Matthieu Patou <mat@matws.net>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/ndr/ndr_basic.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index e56021b606..5c653c8e3b 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -32,6 +32,8 @@
#define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0)
+static void ndr_dump_data(struct ndr_print *ndr, const uint8_t *buf, int len);
+
/*
check for data leaks from the server by looking for non-zero pad bytes
these could also indicate that real structure elements have been
@@ -1162,14 +1164,15 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
const uint8_t *data, uint32_t count)
{
int i;
+#define _ONELINE_LIMIT 32
if (data == NULL) {
ndr->print(ndr, "%s: ARRAY(%d) : NULL", name, count);
return;
}
- if (count <= 600 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {
- char s[1202];
+ if (count <= _ONELINE_LIMIT && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {
+ char s[(_ONELINE_LIMIT + 1) * 2];
for (i=0;i<count;i++) {
snprintf(&s[i*2], 3, "%02x", data[i]);
}
@@ -1179,6 +1182,11 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
}
ndr->print(ndr, "%s: ARRAY(%d)", name, count);
+ if (count > _ONELINE_LIMIT && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {
+ ndr_dump_data(ndr, data, count);
+ return;
+ }
+
ndr->depth++;
for (i=0;i<count;i++) {
char *idx=NULL;
@@ -1188,6 +1196,7 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
}
}
ndr->depth--;
+#undef _ONELINE_LIMIT
}
static void ndr_print_asc(struct ndr_print *ndr, const uint8_t *buf, int len)