CID 976378: Avoid incorrect computation with ngrps == 0

This commit is contained in:
christos 2014-05-28 14:55:16 +00:00
parent 721439951a
commit 6df7376e9e

View File

@ -1,4 +1,4 @@
/* $NetBSD: socket.h,v 1.109 2014/04/17 16:14:22 christos Exp $ */
/* $NetBSD: socket.h,v 1.110 2014/05/28 14:55:16 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -341,7 +341,8 @@ struct sockcred {
* Compute size of a sockcred structure with groups.
*/
#define SOCKCREDSIZE(ngrps) \
(sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
(sizeof(struct sockcred) + (sizeof(gid_t) * \
((ngrps) ? ((ngrps) - 1) : 0)))
#endif /* _NETBSD_SOURCE */