02.06.2023 20:48, Peter Maydell wrote:
Coverity doesn't like the way we might end up calling getgroups()
with a NULL grouplist pointer. This is fine for the special case
of gidsetsize == 0, but we will also do it if the guest passes
us a negative gidsetsize. (CID 1512465)
Explicitly fail the negative gidsetsize with EINVAL, as the kernel
does. This means we definitely only call the libc getgroups()
with valid parameters.
Possibly Coverity may still complain about getgroups(0, NULL), but
that would be a false positive.
Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>
I especially kept the negative case like this when initially writing
this code, thinking to return whatever error the kernel will return.
But I guess it doesn't really matter here, and the less fragile corner
cases, the better.
Reviewed-by: Michael Tokarev <m...@tls.msk.ru>
Thanks,
/mjt