diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-11-06 16:31:31 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-06 17:50:42 -0800 |
commit | 9f029f540c2f7e010e4922d44ba0dfd05da79f88 (patch) | |
tree | 78fea77298162d02e9d9d252cf746b2b685fdeb9 /lib/kstrtox.h | |
parent | 8de1ee7ebfb4979c6444e81273e12e7a972c367d (diff) | |
download | linux-9f029f540c2f7e010e4922d44ba0dfd05da79f88.tar.gz linux-9f029f540c2f7e010e4922d44ba0dfd05da79f88.tar.bz2 linux-9f029f540c2f7e010e4922d44ba0dfd05da79f88.zip |
lib/hexdump.c: truncate output in case of overflow
There is a classical off-by-one error in case when we try to place, for
example, 1+1 bytes as hex in the buffer of size 6. The expected result is
to get an output truncated, but in the reality we get 6 bytes filed
followed by terminating NUL.
Change the logic how we fill the output in case of byte dumping into
limited space. This will follow the snprintf() behaviour by truncating
output even on half bytes.
Fixes: 114fc1afb2de (hexdump: make it return number of bytes placed in buffer)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Tested-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/kstrtox.h')
0 files changed, 0 insertions, 0 deletions