]> git.cameronkatri.com Git - cgit.git/commitdiff
ui-ssdiff: ban strncat()
authorChristian Hesse <mail@eworm.de>
Tue, 12 Feb 2019 20:53:02 +0000 (21:53 +0100)
committerChristian Hesse <mail@eworm.de>
Wed, 5 Jun 2019 13:37:49 +0000 (15:37 +0200)
Git version v2.21.0 marks strncat() as banned (commit
ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.

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

index b6dc5b0578ba68589a4eba8b38d47c27b5012db4..af8bc9e0659bff07c1cf51733ef15b4cd37ea990 100644 (file)
@@ -117,7 +117,7 @@ static char *replace_tabs(char *line)
        int n_tabs = 0;
        int i;
        char *result;
-       int result_len;
+       size_t result_len;
 
        if (linelen == 0) {
                result = xmalloc(1);
@@ -136,10 +136,12 @@ static char *replace_tabs(char *line)
        for (;;) {
                cur_buf = strchr(prev_buf, '\t');
                if (!cur_buf) {
-                       strncat(result, prev_buf, result_len);
+                       linelen = strlen(result);
+                       strlcpy(&result[linelen], prev_buf, result_len - linelen + 1);
                        break;
                } else {
-                       strncat(result, prev_buf, cur_buf - prev_buf);
+                       linelen = strlen(result);
+                       strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1);
                        linelen = strlen(result);
                        memset(&result[linelen], ' ', 8 - (linelen % 8));
                        result[linelen + 8 - (linelen % 8)] = '\0';