-
Committer:
Alex Murray
-
Date:
2019-07-09 02:14:40 UTC
-
Revision ID:
alex.murray@canonical.com-20190709021440-faja4m1nh60l2y97
src/utils.c: Don't use strncpy where strcpy will suffice
The code is already very careful to allocate a buffer large enough for the
length of the filename extension so there is no need to use strncpy to
append this to the new filename - instead can just use strcpy.
With the previous code, whoopsie would FTBFS against gcc 8.3.0 due to the
following error as a result of this use of strncpy - so changing to strcpy
fixes the build:
In file included from /usr/include/string.h:494,
from src/utils.c:19:
In function ‘strncpy’,
inlined from ‘change_file_extension’ at src/utils.c:92:5,
inlined from ‘change_file_extension’ at src/utils.c:67:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/utils.c: In function ‘change_file_extension’:
src/utils.c:89:15: note: length computed here
89 | ext_len = strlen (extension);
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors