From: Samir Benmendil Date: Wed, 9 Jun 2021 00:21:46 +0000 (+0100) Subject: hexdump: correctly display signed single byte integers X-Git-Tag: v2.38-rc1~474^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa6d42f16f22fbe015485a60fa74222b28e3147e;p=thirdparty%2Futil-linux.git hexdump: correctly display signed single byte integers When using the format string '/1 "%d"', the byte did not display as a signed integer as expected, it was interpreted as unsigned. --- diff --git a/text-utils/hexdump-display.c b/text-utils/hexdump-display.c index 695b4724b5..bc92bd0ca0 100644 --- a/text-utils/hexdump-display.c +++ b/text-utils/hexdump-display.c @@ -145,13 +145,15 @@ print(struct hexdump_pr *pr, unsigned char *bp) { } case F_INT: { + char cval; /* int8_t */ short sval; /* int16_t */ int ival; /* int32_t */ long long Lval; /* int64_t, int64_t */ switch(pr->bcnt) { case 1: - printf(pr->fmt, (unsigned long long) *bp); + memmove(&cval, bp, sizeof(cval)); + printf(pr->fmt, (unsigned long long) cval); break; case 2: memmove(&sval, bp, sizeof(sval));