Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-27 Thread Samuel Thibault
Sergey Bugaev, le mar. 27 avril 2021 11:57:03 +0300, a ecrit: > lib.c:154:3: warning: ‘strncpy’ specified bound depends on the length > of the source argument [-Wstringop-overflow=] > It is my understanding, based on > https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059, that GCC does not > do any

Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-27 Thread Sergey Bugaev
On Mon, Apr 26, 2021 at 11:10 PM Samuel Thibault wrote: > Err, but wouldn't the compiler be able to determine that the size was > properly computed, and avoid emitting a false-positive warning? It is my understanding, based on https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059, that GCC does not

Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-26 Thread Samuel Thibault
Sergey Bugaev, le lun. 26 avril 2021 22:34:45 +0300, a ecrit: > On Mon, Apr 26, 2021 at 9:02 PM Jessica Clarke wrote: > > > - strncpy (filepath, path, length); > > > - strncat (filepath, filename, strlen (filename)); > > > + strcpy (filepath, path); > > > + strcat (filepath, filename); > > > >

Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-26 Thread Sergey Bugaev
On Mon, Apr 26, 2021 at 9:02 PM Jessica Clarke wrote: > > - 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. To exp

Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-26 Thread Samuel Thibault
Jessica Clarke, le lun. 26 avril 2021 19:02:54 +0100, a ecrit: > On 26 Apr 2021, at 18:08, Sergey Bugaev 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 prope

Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-26 Thread Jessica Clarke
On 26 Apr 2021, at 18:08, Sergey Bugaev 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 fi

[PATCH unionfs 3/3] Don't use strncat() with length derived from source string

2021-04-26 Thread Sergey Bugaev
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