Commit 35d1e519 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Avoid sign-extension in hexdump

parent e8bb7ec5
......@@ -107,8 +107,7 @@ void vtc_fatal(struct vtclog *vl, const char *, ...)
__attribute__((__noreturn__)) __v_printflike(2,3);
void vtc_dump(struct vtclog *vl, int lvl, const char *pfx,
const char *str, int len);
void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
const char *str, int len);
void vtc_hexdump(struct vtclog *, int , const char *, const void *, int );
int vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
const struct suckaddr *sas);
......
......@@ -231,17 +231,18 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len)
void
vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
const char *str, int len)
const void *ptr, int len)
{
int nl = 1;
unsigned l;
const uint8_t *ss = ptr;
AN(pfx);
GET_VL(vl);
if (str == NULL)
if (ss == NULL)
vtc_leadin(vl, lvl, "%s(null)\n", pfx);
else {
for (l = 0; l < len; l++, str++) {
for (l = 0; l < len; l++, ss++) {
if (l > 512) {
VSB_printf(vl->vsb, "...");
break;
......@@ -250,7 +251,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
vtc_leadin(vl, lvl, "%s| ", pfx);
nl = 0;
}
VSB_printf(vl->vsb, " %02x", *str);
VSB_printf(vl->vsb, " %02x", *ss);
if ((l & 0xf) == 0xf) {
VSB_printf(vl->vsb, "\n");
nl = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment