Commit d0eec99ce50baa5cc2ac02363cdb2a771ed4e1e2
Committed by
Linus Torvalds
1 parent
6454d1f903
Exists in
master
and in
4 other branches
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: Randy Dunlap <randy.dunlap@oracle.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff
lib/hexdump.c
... | ... | @@ -106,7 +106,8 @@ |
106 | 106 | while (lx < (linebuflen - 1) && lx < (ascii_column - 1)) |
107 | 107 | linebuf[lx++] = ' '; |
108 | 108 | for (j = 0; (j < rowsize) && (j < len) && (lx + 2) < linebuflen; j++) |
109 | - linebuf[lx++] = isprint(ptr[j]) ? ptr[j] : '.'; | |
109 | + linebuf[lx++] = (isascii(ptr[j]) && isprint(ptr[j])) ? ptr[j] | |
110 | + : '.'; | |
110 | 111 | nil: |
111 | 112 | linebuf[lx++] = '\0'; |
112 | 113 | } |