bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Samuel Thibault
Subject: Re: [PATCH unionfs 3/3] Don't use strncat() with length derived from source string
Date: Mon, 26 Apr 2021 20:15:20 +0200
User-agent: NeoMutt/20170609 (1.8.3)

Jessica Clarke, le lun. 26 avril 2021 19:02:54 +0100, a ecrit:
> On 26 Apr 2021, at 18:08, Sergey Bugaev <bugaevc@gmail.com> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]