From 6df7376e9ef5ae86d77168d8c10cd8b7fb0945c7 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 28 May 2014 14:55:16 +0000 Subject: [PATCH] CID 976378: Avoid incorrect computation with ngrps == 0 --- sys/sys/socket.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 57aabc977085..f6507f8b2f30 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -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 */