r21334: compare the original buffer and the validated one byte by byte
authorStefan Metzmacher <metze@samba.org>
Wed, 14 Feb 2007 13:24:37 +0000 (13:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:48:14 +0000 (14:48 -0500)
and print out the first mismatch

metze
(This used to be commit 6ac574660a0656341d7a311738d20b328f31ff78)

source4/utils/ndrdump.c

index 9e224c8137ee494aedf2907a656b4bf1aea8c7e0..affdc60b4a55c02452db7a2e01d8699626ffed37 100644 (file)
@@ -329,6 +329,9 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin,
                struct ndr_push *ndr_v_push;
                struct ndr_pull *ndr_v_pull;
                struct ndr_print *ndr_v_print;
+               uint32_t i;
+               uint8_t byte_a, byte_b;
+               bool differ;
 
                ndr_v_push = ndr_push_init_ctx(mem_ctx);
                
@@ -367,11 +370,36 @@ const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin,
                f->ndr_print(ndr_v_print, function, flags, v_st);
 
                if (blob.length != v_blob.length) {
-                       printf("WARNING! orig bytes:%ld validated pushed bytes:%ld\n", (long)blob.length, (long)v_blob.length);
+                       printf("WARNING! orig bytes:%u validated pushed bytes:%u\n", blob.length, v_blob.length);
                }
 
                if (ndr_pull->offset != ndr_v_pull->offset) {
-                       printf("WARNING! orig pulled bytes:%d validated pulled bytes:%d\n", ndr_pull->offset, ndr_v_pull->offset);
+                       printf("WARNING! orig pulled bytes:%u validated pulled bytes:%u\n", ndr_pull->offset, ndr_v_pull->offset);
+               }
+
+               differ = false;
+               byte_a = 0x00;
+               byte_b = 0x00;
+               for (i=0; i < blob.length; i++) {
+                       byte_a = blob.data[i];
+
+                       if (i == v_blob.length) {
+                               byte_b = 0x00;
+                               differ = true;
+                               break;
+                       }
+
+                       byte_b = v_blob.data[i];
+
+                       if (byte_a != byte_b) {
+                               differ = true;
+                               break;
+                       }
+               }
+               if (differ) {
+                       printf("WARNING! orig and validated differ at byte 0x%02X (%u)\n", i, i);
+                       printf("WARNING! orig byte[0x%02X] = 0x%02X validated byte[0x%02X] = 0x%02X\n",
+                               i, byte_a, i, byte_b);
                }
        }