Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jun 2009 23:32:24 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194796 - head/usr.bin/hexdump
Message-ID:  <200906232332.n5NNWOrM095058@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++;
 	}



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