about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorChristian Hesse2018-08-28 20:33:02 +0200
committerChristian Hesse2018-09-11 08:47:12 +0200
commit2fc008d6dea2456548825c973a5516b5cdfd9c8c (patch)
tree9d900eded274af71e15f4d721f8ccee512b5b839 /ui-shared.c
parentui-patch: ban sprintf() (diff)
downloadcgit-2fc008d6dea2456548825c973a5516b5cdfd9c8c.tar.gz
cgit-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>
Diffstat (limited to 'ui-shared.c')
-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,
1159 1159
1160void cgit_set_title_from_path(const char *path) 1160void cgit_set_title_from_path(const char *path)
1161{ 1161{
1162 size_t path_len, path_index, path_last_end; 1162 size_t path_len, path_index, path_last_end, line_len;
1163 char *new_title; 1163 char *new_title;
1164 1164
1165 if (!path) 1165 if (!path)
@@ -1176,14 +1176,18 @@ void cgit_set_title_from_path(const char *path)
1176 continue; 1176 continue;
1177 } 1177 }
1178 strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1); 1178 strncat(new_title, &path[path_index + 1], path_last_end - path_index - 1);
1179 strcat(new_title, "\\"); 1179 line_len = strlen(new_title);
1180 new_title[line_len++] = '\\';
1181 new_title[line_len] = '\0';
1180 path_last_end = path_index; 1182 path_last_end = path_index;
1181 } 1183 }
1182 } 1184 }
1183 if (path_last_end) 1185 if (path_last_end)
1184 strncat(new_title, path, path_last_end); 1186 strncat(new_title, path, path_last_end);
1185 1187
1186 strcat(new_title, " - "); 1188 line_len = strlen(new_title);
1187 strcat(new_title, ctx.page.title); 1189 memcpy(&new_title[line_len], " - ", 3);
1190 new_title[line_len + 3] = '\0';
1191 strncat(new_title, ctx.page.title, sizeof(new_title) - strlen(new_title) - 1);
1188 ctx.page.title = new_title; 1192 ctx.page.title = new_title;
1189} 1193}