pcrs.c:284:14: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
284 | text = strncpy(text, replacement, length + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pcrs.c: In function 'pcrs_compile':
pcrs.c:268:13: note: length computed here
268 | length = strlen(replacement);
| ^~~~~~~~~~~~~~~~~~~
While the warning is correct, the length of the destination
argument also depends on the length of the source argument
so we're good.
Using strlcpy() instead of strncpy() suppresses the warning
and 'text' is filled with zeros anyway so the difference
doesn't matter.
Reported by Lee.
*/
if (trivialflag)
{
- text = strncpy(text, replacement, length + 1);
+ strlcpy(text, replacement, length + 1);
k = (int)length;
}