Truncate negative lengths to zero

This commit is contained in:
Poul-Henning Kamp 2017-11-27 09:57:37 +00:00
parent ed3e292c7a
commit 22adaea1ee

View File

@ -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;