diff options
author | Andy Green <andy@warmcat.com> | 2018-06-26 18:29:56 +0800 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2018-06-29 07:53:20 +0800 |
commit | 2d789a817bd580670107125cb312e33a24bf8045 (patch) | |
tree | 500d7db1ef57951d5b550fa73dff222735e04e44 | |
parent | 9fc611c89f6662175dfeb007023754d038c79451 (diff) | |
download | cgit-2d789a817bd580670107125cb312e33a24bf8045.tar.gz |
gcc8.1: fix strncpy bounds warnings
These warnings are coming on default Fedora 28 build and probably others using gcc 8.1
../shared.c: In function ‘expand_macro’:
../shared.c:483:3: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
strncpy(name, value, len);
^~~~~~~~~~~~~~~~~~~~~~~~~
../shared.c:480:9: note: length computed here
len = strlen(value);
^~~~~~~~~~~~~
strncpy with a computed length via strlen is usually
not the right thing.
Signed-off-by: Andy Green <andy@warmcat.com>
-rw-r--r-- | shared.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -483,7 +483,7 @@ static char *expand_macro(char *name, int maxlength) len = strlen(value); if (len > maxlength) len = maxlength; - strncpy(name, value, len); + memcpy(name, value, len); } return name + len; } |