From e9cad43bee51775820b2e9708b6e1cf99bacc497 Mon Sep 17 00:00:00 2001 From: angt Date: Tue, 10 Nov 2015 21:50:31 +0100 Subject: [PATCH] Simplify dump_ip_header() --- main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 33affd7..2041005 100644 --- a/main.c +++ b/main.c @@ -493,15 +493,18 @@ static int decrypt_packet (struct crypto_ctx *ctx, uint8_t *packet, size_t size, static void dump_ip_header (uint8_t *data, size_t size) { - const char tbl[] = "0123456789ABCDEF"; - size_t hex_size = (size<20)?size:20; - char hex[(20<<1)+1]; + if (size<20) + return; - for (size_t i=0; i>4)]; - hex[(i<<1)+1] = tbl[0xF&data[i]]; + hex[(i<<1)+1] = tbl[0xF&(data[i])]; } - hex[20<<1] = 0; + + hex[40] = 0; fprintf(stderr, "DUMP(%zu): %s\n", size, hex); }