about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2018-08-28 20:33:02 +0200
committerChristian Hesse <mail@eworm.de>2018-09-11 08:47:12 +0200
commit2fc008d6dea2456548825c973a5516b5cdfd9c8c (patch)
tree9d900eded274af71e15f4d721f8ccee512b5b839
parentui-patch: ban sprintf() (diff)
downloadcgit-pink-2fc008d6dea2456548825c973a5516b5cdfd9c8c.tar.gz
cgit-pink-2fc008d6dea2456548825c973a5516b5cdfd9c8c.zip
ui-shared: ban strcat()
Git upstream bans strcat() with commit:

  banned.h: mark strcat() as banned
  1b11b64b815db62f93a04242e4aed5687a448748

To avoid compiler warnings from gcc 8.1.x we get the hard way.

Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r--ui-shared.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 739505a..b53c56d 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1159,7 +1159,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
 
 void cgit_set_title_from_path(const char *path)
 {
-	size_t path_len, path_index, path_last_end;
+	size_t path_len, path_index, path_last_end, line_len;
 	char *new_title;
 
 	if (!path)
@@ -1176,14 +1176,18 @@ void cgit_set_title_from_path(const char *path)
 				continue;
 			}
 			strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1);
-			strcat(new_title, "\\");
+			line_len = strlen(new_title);
+			new_title[line_len++] = '\\';
+			new_title[line_len] = '\0';
 			path_last_end = path_index;
 		}
 	}
 	if (path_last_end)
 		strncat(new_title, path, path_last_end);
 
-	strcat(new_title, " - ");
-	strcat(new_title, ctx.page.title);
+	line_len = strlen(new_title);
+	memcpy(&new_title[line_len], " - ", 3);
+	new_title[line_len + 3] = '\0';
+	strncat(new_title, ctx.page.title, sizeof(new_title) - strlen(new_title) - 1);
 	ctx.page.title = new_title;
 }
URL printing to ui-shared.cJohn Keeping 2014-12-23Remove trailing slash after remove-suffixLukas Fleischer 2014-12-23git: update to v2.2.1Christian Hesse 2014-12-13filter: fix libravatar email-filter https issueChristian Hesse 2014-12-13ui-diff: add "stat only" diff typeJohn Keeping 2014-12-13Change "ss" diff flag to an enumJohn Keeping 2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_diff_link()John Keeping 2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_commit_link()John Keeping 2014-08-07git: update to v2.0.4John Keeping 2014-08-07Always check if README exists in choose_readme()Lukas Fleischer 2014-08-01cgitrc.5: we mean a cgi response, not requestJason A. Donenfeld 2014-07-28ui-stats.c: set parent pointer to NULL after freeing itJohn Keeping 2014-07-28git: update to v2.0.3John Keeping 2014-07-28parsing.c: make commit buffer constJohn Keeping 2014-06-30Bump version.Jason A. Donenfeld 2014-06-29remove debug fprinf() calls that sneaked in with commit 79c985Christian Hesse 2014-06-28git: update to 2.0.1Christian Hesse 2014-06-28ui-patch: Flush stdout after outputting dataJohn Keeping 2014-06-28ui-log: ignore unhandled argumentsJohn Keeping 2014-06-28git: update for git 2.0Christian Hesse 2014-04-17remove trailing whitespaces from source filesChristian Hesse 2014-04-12git: update to 1.9.2Christian Hesse 2014-04-05Fix cgit_parse_url when a repo url is contained in another repo urlJulian Maurice 2014-03-20Makefile: use more reliable git tarball mirrorJason A. Donenfeld 2014-03-20git: update to 1.9.1Christian Hesse