List for cgit developers and users
 help / color / mirror / Atom feed
From: list at eworm.de (Christian Hesse)
Subject: [PATCH v2 1/1] ui-ssdiff: ban strncat()
Date: Tue, 12 Feb 2019 21:55:31 +0100	[thread overview]
Message-ID: <20190212205532.27161-1-list@eworm.de> (raw)
In-Reply-To: <20190208214812.26937-1-list@eworm.de>

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';


  parent reply	other threads:[~2019-02-12 20:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 10:21 [PATCH 1/1] RFC: git: update to v2.21.0-rc0 list
2019-02-07 10:57 ` john
2019-02-08 21:48   ` [PATCH 1/2] ui-ssdiff: ban strncat() list
2019-02-09 11:31     ` Jason
2019-02-10 13:08       ` list
2019-02-12 20:07       ` list
2019-02-12 20:55     ` list [this message]
2019-02-13  8:29       ` [PATCH v2 1/1] " e
2019-02-14 22:41         ` list

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212205532.27161-1-list@eworm.de \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).