Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2017 09:57:37 +0000 (UTC)
From:      Poul-Henning Kamp <phk@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326246 - head/lib/libc/stdio
Message-ID:  <201711270957.vAR9vbRh063859@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: phk
Date: Mon Nov 27 09:57:37 2017
New Revision: 326246
URL: https://svnweb.freebsd.org/changeset/base/326246

Log:
  Truncate negative lengths to zero

Modified:
  head/lib/libc/stdio/xprintf_hexdump.c

Modified: head/lib/libc/stdio/xprintf_hexdump.c
==============================================================================
--- head/lib/libc/stdio/xprintf_hexdump.c	Mon Nov 27 04:24:48 2017	(r326245)
+++ head/lib/libc/stdio/xprintf_hexdump.c	Mon Nov 27 09:57:37 2017	(r326246)
@@ -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 
 	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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711270957.vAR9vbRh063859>