svn commit: r194796 - head/usr.bin/hexdump

Xin LI delphij at FreeBSD.org
Tue Jun 23 23:32:24 UTC 2009


Author: delphij
Date: Tue Jun 23 23:32:24 2009
New Revision: 194796
URL: http://svn.freebsd.org/changeset/base/194796

Log:
  Use strlcpy() instead of explicitly set \0 on the tail of the array.

Modified:
  head/usr.bin/hexdump/parse.c

Modified: head/usr.bin/hexdump/parse.c
==============================================================================
--- head/usr.bin/hexdump/parse.c	Tue Jun 23 23:30:56 2009	(r194795)
+++ head/usr.bin/hexdump/parse.c	Tue Jun 23 23:32:24 2009	(r194796)
@@ -142,8 +142,7 @@ add(const char *fmt)
 				badfmt(fmt);
 		if (!(tfu->fmt = malloc(p - savep + 1)))
 			err(1, NULL);
-		(void) strncpy(tfu->fmt, savep, p - savep);
-		tfu->fmt[p - savep] = '\0';
+		(void) strlcpy(tfu->fmt, savep, p - savep + 1);
 		escape(tfu->fmt);
 		p++;
 	}


More information about the svn-src-all mailing list