From: deraadt Date: Sun, 5 Mar 2000 20:32:13 +0000 (+0000) Subject: fix size check case for getgroups; pbucich@sion.com X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e3aab2e1f69ac3f9d58ef5eefbb21160a0e55132;p=openbsd fix size check case for getgroups; pbucich@sion.com --- diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c index 793eaba953a..b817aac8f6c 100644 --- a/sys/compat/ibcs2/ibcs2_misc.c +++ b/sys/compat/ibcs2/ibcs2_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ibcs2_misc.c,v 1.14 1999/02/10 00:16:11 niklas Exp $ */ +/* $OpenBSD: ibcs2_misc.c,v 1.15 2000/03/05 20:32:13 deraadt Exp $ */ /* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */ /* @@ -638,13 +638,15 @@ ibcs2_sys_getgroups(p, v, retval) } if ((error = sys_getgroups(p, &sa, retval)) != 0) return error; - for (i = 0, gp = SCARG(&sa, gidset); i < retval[0]; i++) - iset[i] = (ibcs2_gid_t)*gp++; - if (retval[0] && (error = copyout((caddr_t)iset, - (caddr_t)SCARG(uap, gidset), - sizeof(ibcs2_gid_t) * retval[0]))) - return error; - return 0; + if (iset) { + for (i = 0, gp = SCARG(&sa, gidset); i < retval[0]; i++) + iset[i] = (ibcs2_gid_t)*gp++; + if (retval[0] && (error = copyout((caddr_t)iset, + (caddr_t)SCARG(uap, gidset), + sizeof(ibcs2_gid_t) * retval[0]))) + return error; + } + return 0; } int