Jessica Clarke, le lun. 26 avril 2021 19:02:54 +0100, a ecrit: > On 26 Apr 2021, at 18:08, Sergey Bugaev <[email protected]> wrote: > > This fixes Wstringop-overflow and Wstringop-truncation GCC warnings. > > See https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059 > > > > Also, fix a bug where a string was not properly null-terminated. > > --- > > lib.c | 4 ++-- > > stow.c | 5 +++-- > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/lib.c b/lib.c > > index 01cdbd0..717979b 100644 > > --- a/lib.c > > +++ b/lib.c > > @@ -151,8 +151,8 @@ make_filepath (char *path, char *filename) > > if (filepath == NULL) > > return NULL; > > > > - strncpy (filepath, path, length); > > - strncat (filepath, filename, strlen (filename)); > > + strcpy (filepath, path); > > + strcat (filepath, filename); > > This is dubious. We should be using safe interfaces where possible.
Yes, we don't want to just ignore the warnings, and actually check where the length is wrong. Samuel
