If a UID/GID is larger than its respective data type allows (but smaller
than uint64_t), then tools like newgrp erroneously assume that the user
or group simply does not exist.
Set errno to indicate that the supplied UID/GID is out of range instead.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
*result = gr->gr_gid;
return gr;
}
- if (num > MAX_OF_UINT_TYPE(gid_t))
+ if (num > MAX_OF_UINT_TYPE(gid_t)) {
+ errno = ERANGE;
return NULL;
+ }
if (result)
*result = (gid_t) num;
*result = pw->pw_uid;
return pw;
}
- if (num > MAX_OF_UINT_TYPE(uid_t))
+ if (num > MAX_OF_UINT_TYPE(uid_t)) {
+ errno = ERANGE;
return NULL;
+ }
if (result)
*result = (uid_t) num;