On Mon, 08 Jul 2019 16:36:05 +0200, Moritz Buhl wrote: > while porting some NetBSD syscall tests to OpenBSD I noticed that the > getgroups test is failing. Simply put: > > gid_t gidset[NGROUPS_MAX]; > getgroups(-1, gidset); > > This was fixed on NetBSD 8 years ago: > http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_prot.c > > if (SCARG(uap, gidsetsize) < (int)*retval) > > return EINVAL; > > While here, also remove the u_int in setgroups. POSIX does't say a lot > about setgroups and therefore return EINVAL. > https://pubs.opengroup.org/onlinepubs/9699919799/
That all makes sense to me. Checking for ngrp<0 in setgroups() makes things easier to understand compared to the implicit cast to uint and relying on the result to be >NGROUPS_MAX. - todd
