diff options
author | Christian Hesse | 2018-08-28 18:23:36 +0200 |
---|---|---|
committer | Christian Hesse | 2018-09-11 08:47:12 +0200 |
commit | a96f2890f41e0b9b0ffa1bcdb1dddbef28c01662 (patch) | |
tree | d88340d58313c6f20e063003d809e158c7295c29 | |
parent | 0899eb644fab415e9a3b304f53da9da50aaf91aa (diff) | |
download | cgit-a96f2890f41e0b9b0ffa1bcdb1dddbef28c01662.tar.gz cgit-a96f2890f41e0b9b0ffa1bcdb1dddbef28c01662.tar.bz2 cgit-a96f2890f41e0b9b0ffa1bcdb1dddbef28c01662.zip |
ui-ssdiff: ban strcat()
Git upstream bans strcat() with commit:
banned.h: mark strcat() as banned
1b11b64b815db62f93a04242e4aed5687a448748
Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r-- | ui-ssdiff.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ui-ssdiff.c b/ui-ssdiff.c index a3dd059..c456033 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c | |||
@@ -117,6 +117,7 @@ static char *replace_tabs(char *line) | |||
117 | int n_tabs = 0; | 117 | int n_tabs = 0; |
118 | int i; | 118 | int i; |
119 | char *result; | 119 | char *result; |
120 | int result_len; | ||
120 | 121 | ||
121 | if (linelen == 0) { | 122 | if (linelen == 0) { |
122 | result = xmalloc(1); | 123 | result = xmalloc(1); |
@@ -128,13 +129,14 @@ static char *replace_tabs(char *line) | |||
128 | if (line[i] == '\t') | 129 | if (line[i] == '\t') |
129 | n_tabs += 1; | 130 | n_tabs += 1; |
130 | } | 131 | } |
131 | result = xmalloc(linelen + n_tabs * 8 + 1); | 132 | result_len = linelen + n_tabs * 8; |
133 | result = xmalloc(result_len + 1); | ||
132 | result[0] = '\0'; | 134 | result[0] = '\0'; |
133 | 135 | ||
134 | for (;;) { | 136 | for (;;) { |
135 | cur_buf = strchr(prev_buf, '\t'); | 137 | cur_buf = strchr(prev_buf, '\t'); |
136 | if (!cur_buf) { | 138 | if (!cur_buf) { |
137 | strcat(result, prev_buf); | 139 | strncat(result, prev_buf, result_len); |
138 | break; | 140 | break; |
139 | } else { | 141 | } else { |
140 | strncat(result, prev_buf, cur_buf - prev_buf); | 142 | strncat(result, prev_buf, cur_buf - prev_buf); |