[PATCH] s3/rpc_server/srvsvc/srv_srvsvc_nt.c: change snum to signed int
Volker.Lendecke at SerNet.DE
Thu Mar 3 16:59:09 UTC 2016
On Thu, Mar 03, 2016 at 04:53:27PM +0100, Aurélien Aptel wrote:
> 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.
Also, I'd swap the (snum<0) and (sharename==NULL) checks.
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
More information about the samba-technical