]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: use xstrncpy in add()
authorOndrej Oprala <ooprala@redhat.com>
Mon, 23 Sep 2013 13:39:23 +0000 (15:39 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Nov 2013 11:54:53 +0000 (12:54 +0100)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
text-utils/parse.c

index 2557210a293ded2f488a94e81ab9df9094619937..24a8407af60f19859f392d9414af15fff0f6dd1f 100644 (file)
@@ -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;
        }