aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
authorJason A. Donenfeld2018-07-04 03:13:31 +0200
committerJason A. Donenfeld2018-07-04 03:13:41 +0200
commit08a2b1b8f812c6d77489467c8ff120979c297bed (patch)
tree68b95757d8f410a82b2f1bb01440cc7cf0e0ed63 /shared.c
parentc4167cbd65acef801e6132ba1182f6ce246ed630 (diff)
downloadcgit-08a2b1b8f812c6d77489467c8ff120979c297bed.tar.gz
cgit-08a2b1b8f812c6d77489467c8ff120979c297bed.tar.bz2
cgit-08a2b1b8f812c6d77489467c8ff120979c297bed.zip
Fix gcc 8.1.1 compiler warnings
CC ../shared.o ../shared.c: In function ‘expand_macro’: ../shared.c:487:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(name, value, len); ^~~~~~~~~~~~~~~~~~~~~~~~~ ../shared.c:484:9: note: length computed here len = strlen(value); ^~~~~~~~~~~~~ ../ui-shared.c: In function ‘cgit_repobasename’: ../ui-shared.c:136:2: warning: ‘strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation] strncpy(rvbuf, reponame, sizeof(rvbuf)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC ../ui-ssdiff.o ../ui-ssdiff.c: In function ‘replace_tabs’: ../ui-ssdiff.c:142:4: warning: ‘strncat’ output truncated copying between 1 and 8 bytes from a string of length 8 [-Wstringop-truncation] strncat(result, spaces, 8 - (strlen(result) % 8)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shared.c b/shared.c
index f7b64cf..609bd2a 100644
--- a/shared.c
+++ b/shared.c
@@ -476,15 +476,16 @@ static int is_token_char(char c)
476static char *expand_macro(char *name, int maxlength) 476static char *expand_macro(char *name, int maxlength)
477{ 477{
478 char *value; 478 char *value;
479 int len; 479 size_t len;
480 480
481 len = 0; 481 len = 0;
482 value = getenv(name); 482 value = getenv(name);
483 if (value) { 483 if (value) {
484 len = strlen(value); 484 len = strlen(value) + 1;
485 if (len > maxlength) 485 if (len > maxlength)
486 len = maxlength; 486 len = maxlength;
487 strncpy(name, value, len); 487 strlcpy(name, value, len);
488 --len;
488 } 489 }
489 return name + len; 490 return name + len;
490} 491}