[PATCH] Enforce strict overflow checking
Andreas Schneider
asn at samba.org
Tue Apr 3 16:10:29 UTC 2018
On Tuesday, 3 April 2018 17:45:25 CEST Jeremy Allison wrote:
> On Tue, Apr 03, 2018 at 02:02:53PM +0200, Andreas Schneider wrote:
> > Ah, sorry my bad. I didn't have the tree with the reverted patch. Here we
> > go:
> >
> >
> > ../source3/nmbd/nmbd_incomingrequests.c: In function
> > ‘process_node_status_request’:
> > ../source3/nmbd/nmbd_incomingrequests.c:344:8: error: assuming pointer
> > wraparound does not occur when comparing P +- C1 with P +- C2
> > [-Werror=strict- overflow]
> >
> > while (buf < bufend) {
> >
> > ^
> >
> > cc1: all warnings being treated as errors
>
> Ah, I'm not seeing that. What version of gcc are you using ?
I'm not seeing them either with gcc 7.3.1 on my machines!
I was only able to reproduce this on sn-devel (autobuild) which uses:
gcc-4.8.real (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
> Are there a lot of these in nmbd ? Is it worth fixing nmbd
> first, or set to ignore now and work on them later ?
I don't know. It might be after fixing that one, that it will find more in
that file.
However fixing this one will probably a bit tricky. The optimizer doesn't like
the pointer arithmetic. So you need to use array indices to do the overflow
calculations. By fixing that we would allow the optimizer to understand the
limitations better.
It is possible that gcc 7 is cleverer than 4.8 in this regard and can deal
with the pointer arithmetic here.
I hope that helps.
Andreas
--
Andreas Schneider GPG-ID: CC014E3D
Samba Team asn at samba.org
www.samba.org
More information about the samba-technical
mailing list