]> git.cameronkatri.com Git - cgit.git/commitdiff
parsing: ban strncpy()
authorChristian Hesse <mail@eworm.de>
Tue, 28 Aug 2018 16:11:50 +0000 (18:11 +0200)
committerChristian Hesse <mail@eworm.de>
Tue, 11 Sep 2018 06:47:12 +0000 (08:47 +0200)
Git upstream bans strncpy() with commit:

  banned.h: mark strncpy() as banned
  e488b7aba743d23b830d239dcc33d9ca0745a9ad

Signed-off-by: Christian Hesse <mail@eworm.de>
parsing.c

index 12453c2db289e1c7812de2cbcdbe128275930f92..e224564dc5346e74300ca35b567a6799f701ca57 100644 (file)
--- a/parsing.c
+++ b/parsing.c
@@ -63,8 +63,7 @@ static char *substr(const char *head, const char *tail)
        if (tail < head)
                return xstrdup("");
        buf = xmalloc(tail - head + 1);
-       strncpy(buf, head, tail - head);
-       buf[tail - head] = '\0';
+       strlcpy(buf, head, tail - head + 1);
        return buf;
 }