Re: [PATCH] git-compat-util: avoid failing dir ownership checks if running privileged
- From
Carlo Arenas <carenas@gmail.com>
- Date
- Apr 27, 2022, 18:11 UTC
- Message-ID
- <CAPUEspgOwmQwqBjauKW=VYJjry3537Te4RLjB=ZuT=CU+rRA4A@mail.gmail.com>
- In-Reply-To
- <00b501d85a61$74130240$5c3906c0$@nexbridge.com>
On Wed, Apr 27, 2022 at 11:06 AM <rsbecker@nexbridge.com> wrote:
> Results on NonStop: strtol("123456789012345678", &endptr, 10) returns 4294967295 and *endptr == '\0' just beyond the last 8.Thanks and errno == ERANGE as POSIX requires, right?, the code (untested) I was planning to use instead looks like :
static inline void extract_id_from_env(const char *env, uid_t *id)
{
const char *real_uid = getenv(env); /* discard any empty values */
if (real_uid && *real_uid) {
unsigned long extracted_id;
int saved_errno = errno; errno = 0;
extracted_id = strtoul(real_uid, NULL, 10);
if (!errno)
*id = (uid_t)extracted_id;
errno = saved_errno;
}
return 0;
}Carlo