From 61ef57aaf242e3d5dac5cd2b55527a685199cf4b Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Wed, 25 Jun 1997 01:01:21 +0000 Subject: [PATCH] Do The Right Thing when an iBCS2 program does getgroups(0, whatever) -- we were returning EFAULT, when it is a completely acceptable thing to do. Also, at the same time, be a *bit* optimizing and don't allocate any "stackgrap" memory if we're not going to use it. This is another Oracle-discovered problem. Submitted by: Steven Wallace --- sys/i386/ibcs2/ibcs2_misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index dfc4bad76bb..a8766757d46 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -45,7 +45,7 @@ * * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93 * - * $Id: ibcs2_misc.c,v 1.19 1997/04/06 14:10:50 dfr Exp $ + * $Id: ibcs2_misc.c,v 1.20 1997/05/07 20:05:44 peter Exp $ */ /* @@ -653,10 +653,14 @@ ibcs2_getgroups(p, uap, retval) if (SCARG(uap, gidsetsize)) { SCARG(&sa, gidset) = stackgap_alloc(&sg, NGROUPS_MAX * sizeof(gid_t *)); + iset = stackgap_alloc(&sg, SCARG(uap, gidsetsize) * + sizeof(ibcs2_gid_t)); } - iset = stackgap_alloc(&sg, SCARG(uap, gidsetsize)*sizeof(ibcs2_gid_t)); if (error = getgroups(p, &sa, retval)) return error; + if (SCARG(uap, gidsetsize) == 0) + return 0; + 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,