diff --git a/src/capdiff.c b/src/capdiff.c index 0912c23..87a4b67 100644 --- a/src/capdiff.c +++ b/src/capdiff.c @@ -49,7 +49,8 @@ int main(int argc, char** argv) { bpread[1].ip.ap.fmt.content.clear.id); }*/ - uint8_t is_same_size = bpread[0].ip.ap.fmt.headers.size == bpread[1].ip.ap.fmt.headers.size; + size_t s1 = bpread[0].ip.ap.fmt.headers.size, s2 = bpread[1].ip.ap.fmt.headers.size; + uint8_t is_same_size = s1 == s2; if (!is_same_size) { printf("[!!] %s packet has size %d, %s packet has size %d for expected id %d\n", argv[1], @@ -65,10 +66,10 @@ int main(int argc, char** argv) { bpread[0].ip.ap.fmt.headers.size); } - size_t s1 = bpread[0].ip.ap.fmt.headers.size, s2 = bpread[1].ip.ap.fmt.headers.size; + size_t max_size = s1 > s2 ? s1 : s2; for (size_t idx = 0; idx < max_size; idx++) { - char e1 = (&bpread[0].ip.ap.raw)[idx], e2 = (&bpread[0].ip.ap.raw)[idx]; + char e1 = (&bpread[0].ip.ap.raw)[idx], e2 = (&bpread[1].ip.ap.raw)[idx]; if (e1 != e2) { printf("[!!] for expected id %d, byte 0x%04x is different: 0x%02x vs 0x%02x\n", expected_id, (uint16_t)idx, (uint8_t)e1, (uint8_t)e2); } @@ -82,6 +83,6 @@ int main(int argc, char** argv) { fclose(fd[i]); } - printf("done\n"); + printf("parsed %d packets\n", expected_id); return 0; }