RE: [PATCH] git-compat-util: avoid failing dir ownership checks if running privileged
- From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
- Date
- Apr 27, 2022, 18:16 UTC
- Message-ID
- <00bd01d85a62$ff56e7d0$fe04b770$@nexbridge.com>
- In-Reply-To
- <CAPUEspgOwmQwqBjauKW=VYJjry3537Te4RLjB=ZuT=CU+rRA4A@mail.gmail.com>
On April 27, 2022 2:12 PM, Carlo Arenas wrote:
Show 23 quoted lines
>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;
>}errno = 4034 (Value out of range), which is the ERANGE #define. --Randall