From: Carlo Arenas Date: Wed, 27 Apr 2022 18:11:37 GMT Subject: Re: [PATCH] git-compat-util: avoid failing dir ownership checks if running privileged Message-ID: In-Reply-To: <00b501d85a61$74130240$5c3906c0$@nexbridge.com> On Wed, Apr 27, 2022 at 11:06 AM 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