mirror of
https://git.zx2c4.com/cgit
synced 2025-08-02 09:05:01 +02:00
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>
This commit is contained in:
parent
c4167cbd65
commit
08a2b1b8f8
3 changed files with 23 additions and 15 deletions
7
shared.c
7
shared.c
|
@ -476,15 +476,16 @@ static int is_token_char(char c)
|
|||
static char *expand_macro(char *name, int maxlength)
|
||||
{
|
||||
char *value;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
len = 0;
|
||||
value = getenv(name);
|
||||
if (value) {
|
||||
len = strlen(value);
|
||||
len = strlen(value) + 1;
|
||||
if (len > maxlength)
|
||||
len = maxlength;
|
||||
strncpy(name, value, len);
|
||||
strlcpy(name, value, len);
|
||||
--len;
|
||||
}
|
||||
return name + len;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue