[PATCHSET] Fix and add -Werror=strict-overflow -Wstrict-overflow=2
Andreas Schneider
asn at samba.org
Thu Dec 7 21:13:31 UTC 2017
On Thursday, 7 December 2017 21:18:54 CET jim via samba-technical wrote:
> This change is wrong. Original code '(nread == 0) || ...' is more correct.
> More rigorous would be (nread == 0) || (nread > 0 && namebuf[nread-1] !=
> '\0').
> nread is 0 resulting in invalid access to namebuf[nread-1] in while
> condition check.
I think we need a do { } while(namebuf[nread-1] != '\0') loop here. This would
fix it correctly.
Do you agree?
>
> On 12/7/2017 2:37 PM, Andreas Schneider via samba-technical wrote:
> > diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
> > index 18b01e6c05e..4ef0a2e34ab 100644
> > --- a/source3/modules/vfs_preopen.c
> > +++ b/source3/modules/vfs_preopen.c
> > @@ -156,7 +156,7 @@ static bool preopen_helper_open_one(int sock_fd, char
> > **pnamebuf,>
> > nread = 0;
> >
> > - while ((nread == 0) || (namebuf[nread-1] != '\0')) {
> > + while (namebuf[nread-1] != '\0') {
> >
> > ssize_t thistime;
> >
> > thistime = read(sock_fd, namebuf + nread,
> >
> > -- 2.15.1
More information about the samba-technical
mailing list