From 7e7765a4515bc23d536e2840c5bbdf18ffca6d45 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 9 Aug 2021 19:37:16 +0200 Subject: [PATCH] BUG/MINOR: buffer: fix buffer_dump() formatting The formatting of the buffer_dump() output must be calculated using the relative counter, not the absolute one, or everything will be broken if the variable is not a multiple of 16. Could be backported in all maintained versions. --- src/dynbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dynbuf.c b/src/dynbuf.c index 0dce210..a200237 100644 --- a/src/dynbuf.c +++ b/src/dynbuf.c @@ -75,7 +75,7 @@ void buffer_dump(FILE *o, struct buffer *b, int from, int to) fprintf(o, " %04x: ", from); for (i = 0; ((from + i) < to) && (i < 16) ; i++) { fprintf(o, "%02x ", (unsigned char)b_orig(b)[from + i]); - if (((from + i) & 15) == 7) + if (i == 7) fprintf(o, "- "); } if (to - from < 16) { @@ -89,7 +89,7 @@ void buffer_dump(FILE *o, struct buffer *b, int from, int to) fprintf(o, " "); for (i = 0; (from + i < to) && (i < 16) ; i++) { fprintf(o, "%c", isprint((unsigned char)b_orig(b)[from + i]) ? b_orig(b)[from + i] : '.') ; - if ((((from + i) & 15) == 15) && ((from + i) != to-1)) + if ((i == 15) && ((from + i) != to-1)) fprintf(o, "\n"); } from += i; -- 1.7.10.4