[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: purpose of *-safer?
From: |
Paul Eggert |
Subject: |
Re: purpose of *-safer? |
Date: |
Thu, 27 Jul 2006 03:24:47 -0400 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
>> And wouldn't there be an easier workaround: At the beginning of main(),
>> use fcntl() to determine whether 0,1,2 are closed, and if so, replace
>> them with open("/dev/null") ?
>
> Possibly. And if we did, it would make more sense to open fd 0 as write
> only and fd 1 as read only, to be more likely to catch attempts to use
> these streams when the user intended them to be closed.
Jim did that in coreutils/lib/stdopen.c, I think with the idea of
migrating it into gnulib if there was demand. Hmm, but this code
currently isn't being used in coreutils. I don't offhand recall why.
Here's what I do recall. I swept coreutils for the sort of problem
that stdopen would cure and fixed then with stdio-safer etc. Jim
wrote stdopen.c in response, since this would be simpler than all
those painstaking sweeps.
If I missed nothing in my sweeps (an unlikely prospect!), then
invoking stdopen merely adds a small amount of bloat to coreutils, and
is unnecessary. A more-important argument against stdopen is that
weird invocations like "cat /dev/fd/2 2>&-" would do the wrong thing.
- Re: split stdio-safer into fopen-safer, tmpfile-safer, (continued)
- Re: split stdio-safer into fopen-safer, tmpfile-safer, Eric Blake, 2006/07/25
- Re: [bug-gnulib] split stdio-safer into fopen-safer, tmpfile-safer, Bruno Haible, 2006/07/26
- Re: split stdio-safer into fopen-safer, tmpfile-safer, Ben Pfaff, 2006/07/26
- Re: split stdio-safer into fopen-safer, tmpfile-safer, Eric Blake, 2006/07/26
- Re: split stdio-safer into fopen-safer, tmpfile-safer, Paul Eggert, 2006/07/27
Re: purpose of *-safer?, Bruno Haible, 2006/07/25
Re: purpose of *-safer?,
Paul Eggert <=
Re: purpose of *-safer?, Jim Meyering, 2006/07/27
Re: split stdio-safer into fopen-safer, tmpfile-safer, Eric Blake, 2006/07/28