Commit d0eec99c authored by Randy Dunlap's avatar Randy Dunlap Committed by Linus Torvalds

hexdump: don't print bytes with bit 7 set

As Herbert Xu pointed out, bytes (chars) with bit 7 (0x80) set are true
with isprint() but they may not be isascii() but be Unicode instead, so
don't try to print them in hex dumps.
Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6454d1f9
...@@ -106,7 +106,8 @@ void hex_dump_to_buffer(const void *buf, size_t len, int rowsize, ...@@ -106,7 +106,8 @@ void hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
while (lx < (linebuflen - 1) && lx < (ascii_column - 1)) while (lx < (linebuflen - 1) && lx < (ascii_column - 1))
linebuf[lx++] = ' '; linebuf[lx++] = ' ';
for (j = 0; (j < rowsize) && (j < len) && (lx + 2) < linebuflen; j++) for (j = 0; (j < rowsize) && (j < len) && (lx + 2) < linebuflen; j++)
linebuf[lx++] = isprint(ptr[j]) ? ptr[j] : '.'; linebuf[lx++] = (isascii(ptr[j]) && isprint(ptr[j])) ? ptr[j]
: '.';
nil: nil:
linebuf[lx++] = '\0'; linebuf[lx++] = '\0';
} }
......
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