1
0
forked from bip/bip

Fix stringop-truncation error (thanks DJ Delorie)

See https://bugzilla.redhat.com/show_bug.cgi?id=1799189. bip build fails
on current Fedora Rawhide GCC and glibc. DJ Delorie says "The warning is
correct; the code is copying up to the NUL on purpose, then copying the
NUL in a separate command.  Not sure why." Tom Hughes suggests this as
the fix.
This commit is contained in:
Adam Williamson 2020-02-07 11:20:45 -08:00 committed by Pierre-Louis Bonicoli
parent c9cc64f2e1
commit 92819d87ea
Signed by untrusted user: pilou
GPG Key ID: 06914C4A5EDAA6DD

View File

@ -631,7 +631,7 @@ static char *get_str_elem(char *str, int num)
if (c - cur < 1)
return NULL;
ret = bip_malloc(c - cur + 1);
strncpy(ret, cur, c - cur);
memcpy(ret, cur, c - cur);
ret[c - cur] = 0;
return ret;
}
@ -640,7 +640,7 @@ static char *get_str_elem(char *str, int num)
if (c - cur < 1)
return NULL;
ret = bip_malloc(c - cur + 1);
strncpy(ret, cur, c - cur);
memcpy(ret, cur, c - cur);
ret[c - cur] = 0;
return ret;
}