Re: [PATCH] git-compat-util: avoid failing dir ownership checks if running privileged
- From
Carlo Arenas <carenas@gmail.com>
- Date
- Apr 27, 2022, 17:49 UTC
- Message-ID
- <CAPUEspjoTYtv9K=rvpkFnyGnEz_uxefED820rx09b6qGG93SqA@mail.gmail.com>
- In-Reply-To
- <6c3b447d-9419-982d-678c-6a6c0ff8cbc2@gmail.com>
On Wed, Apr 27, 2022 at 10:28 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 7 quoted lines
> > On 27/04/2022 17:54, Carlo Arenas wrote: > > > > the only thing that worries me is sign extension but that is why I put > > a specific cast. for all practical reasons I expect uid_t to be > > uint32_t and therefore using long should be better than using int > > (through atoi)
Well, just because I think that is the most likely option, doesn't mean it will be so since it is not defined as such in the standard. I should have documented though that I was (probably incorrectly) prioritizing the possibility of supporting negative uids instead of positive uids > INT_MAX.
This of course only matters in 32bit, but looking at sudo's sources they use "%u" to set the UID in the environment and therefore we should change our approach to match.
> If we think uid_t is a uint32_t then should we be using strtoul() to > make sure we cover the whole uid range where sizeof(long) == > sizeof(uint32_t)?
strtoul is sadly not very portable, but I think you are correct that it should be used instead originally I thought it would be better to do strtoimax but that will also require moving this function around.
Carlo