[musl] Re: [shadow-maint/shadow] Add cheap defense mechanisms (PR #1171)
Alejandro Colomar
alx@kernel.org
Mon Feb 17 15:08:02 GMT 2025
Hi Rich,
On Mon, Feb 17, 2025 at 09:44:58AM -0500, Rich Felker wrote:
> It's in the latest POSIX and we have supported it for a long time as
> POSIX-future (since 2012/release 0.9.7).
Thanks! That agrees with my own research.
> > > Isn't it safe to use constructs like
> > > ``` C
> > > shadow = fopen (SGROUP_FILE, "re");
> > > if (NULL == shadow )
> > > shadow = fopen (SGROUP_FILE, "r");
> > > ```
> > > ?
>
> Unfortunately this doesn't work because it's UB to pass any modes but
> the standards-specified ones.
Makes sense. Thanks!
> In any case use of fopen is just gratuitously bad for software that
> targets POSIX. The right way to do things is a two-step open+fdopen.
> This avoids needing to depend on new features to open and lets you use
> all the modern open flags, openat if needed, etc.
Hmmm, thanks for the idea! This code is old, so we didn't actually
write it; we only added 'e' recently to it. If we need to write new
code, I'll take into consideration doing that as a two-step process,
maybe adding a wrapper around that process.
Have a lovely day!
Alex
> P.S. Had to omit shadow-utils <~hallyn/shadow@lists.sr.ht> from CC
> because my mail software rejects / in an address... gotta fix that.
> Apologies.
No problem. Thanks!
--
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-help/attachments/20250217/7bc2e6b9/attachment-0001.sig>
More information about the Libc-help
mailing list