]> git.cameronkatri.com Git - cgit.git/commitdiff
ui-ssdiff: ban strncpy()
authorChristian Hesse <mail@eworm.de>
Tue, 28 Aug 2018 16:22:26 +0000 (18:22 +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>
ui-ssdiff.c

index 68c2044dcc75c8ab58df847c36e0debe3665acba..a3dd0592d84a7379101538c027bb0fea8d8f0279 100644 (file)
@@ -103,8 +103,7 @@ static int line_from_hunk(char *line, char type)
                return 0;
        len = buf2 - buf1;
        buf2 = xmalloc(len + 1);
-       strncpy(buf2, buf1, len);
-       buf2[len] = '\0';
+       strlcpy(buf2, buf1, len + 1);
        res = atoi(buf2);
        free(buf2);
        return res;