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 <from> variable is not a multiple of 16.
Could be backported in all maintained versions.
(cherry picked from commit 7e7765a4515bc23d536e2840c5bbdf18ffca6d45)
Signed-off-by: Willy Tarreau <w@1wt.eu>
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 @@
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 @@
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;