diff --git a/lib/libc/stdio/xprintf_hexdump.c b/lib/libc/stdio/xprintf_hexdump.c index 73f98a8fb53f..0b7dfb3ff221 100644 --- a/lib/libc/stdio/xprintf_hexdump.c +++ b/lib/libc/stdio/xprintf_hexdump.c @@ -50,6 +50,7 @@ int __printf_render_hexdump(struct __printf_io *io, const struct printf_info *pi, const void *const *arg) { unsigned char *p; + int i; unsigned u, l, j, a; char buf[100], *q; int ret; @@ -59,7 +60,10 @@ __printf_render_hexdump(struct __printf_io *io, const struct printf_info *pi, co else l = 16; p = *((unsigned char **)arg[0]); - u = *((unsigned *)arg[1]); + i = *((int *)arg[1]); + if (i < 0) + i = 0; + u = i; ret = 0; a = 0;