[PATCH v2 1/1] ui-ssdiff: ban strncat()
Christian Hesse
list at eworm.de
Tue Feb 12 21:55:31 CET 2019
From: Christian Hesse <mail at eworm.de>
Git version v2.21.0 marks strncat() as banned (commit
ace5707a803eda0f1dde3d776dc3729d3bc7759a), so replace it.
Signed-off-by: Christian Hesse <mail at eworm.de>
---
ui-ssdiff.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index c456033..a5892fb 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -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';
More information about the CGit
mailing list