[PATCH] s3/rpc_server/srvsvc/srv_srvsvc_nt.c: change snum to signed int

Jeremy Allison jra at samba.org
Fri Mar 4 17:53:24 UTC 2016


On Thu, Mar 03, 2016 at 05:59:09PM +0100, Volker Lendecke wrote:
> On Thu, Mar 03, 2016 at 04:53:27PM +0100, Aurélien Aptel wrote:
> > Hi,
> > 
> > Another PVS fix:
> > 
> > snum is used to store the result of the find_service() call which
> > returns a signed int, with -1 being an error.
> >     
> > As an uint32_t the implicit cast converts -1 to UINT32_MAX in snum and
> > the error check (< 0) is always false.
> > 
> > The attached patch defines snum as an int instead of uint32_t. When
> > snum is subsequently passed to count_share_opens() as an uint32_t the
> > implicit cast from a positive int to uint32_t is always safe AFAIK.
> > 
> > An alternative fix would be to replace the < 0 check with == UINT32_MAX
> > or == -1 which are equivalent (signed values are always casted to
> > unsigned in signed/unsigned comparison, e.g. -1 > 1U is true).
> > 
> > Please review/comment
> 
> 100% correct. R-B me.

LGTM. Pushed !



More information about the samba-technical mailing list