From: Ondrej Oprala Date: Mon, 23 Sep 2013 13:39:23 +0000 (+0200) Subject: hexdump: use xstrncpy in add() X-Git-Tag: v2.25-rc1~757 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bec2d4582f9fe4b467709501e91e804ec1c5d21e;p=thirdparty%2Futil-linux.git hexdump: use xstrncpy in add() Signed-off-by: Ondrej Oprala --- diff --git a/text-utils/parse.c b/text-utils/parse.c index 2557210a29..24a8407af6 100644 --- a/text-utils/parse.c +++ b/text-utils/parse.c @@ -44,6 +44,7 @@ #include "hexdump.h" #include "nls.h" #include "xalloc.h" +#include "strutils.h" static void escape(char *p1); static void badcnt(const char *s); @@ -148,8 +149,7 @@ void add(const char *fmt) badfmt(fmt); } tfu->fmt = xmalloc(p - savep + 1); - strncpy(tfu->fmt, (char *)savep, p - savep); - tfu->fmt[p - savep] = '\0'; + xstrncpy(tfu->fmt, (char *)savep, p - savep + 1); escape(tfu->fmt); ++p; }