bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bugs when operating with closed file descriptors


From: Gary V. Vaughan
Subject: Re: bugs when operating with closed file descriptors
Date: Mon, 21 Aug 2006 11:39:30 +0100

Hi Eric,

(Another!) Nice catch :-)

Even in the absence of any fixes, making these sorts of issues into tests as we find them serves both to document known shortcomings and to prevent
future regressions when the problems have been fixed -- an excellent way
to make the source code robust...

Cheers,
        Gary.

On 18 Aug 2006, at 20:58, Eric Blake wrote:

Eric Blake <ebb9 <at> byu.net> writes:


I'm still thinking about how best to patch this. I know gnulib provides the stdio-safer module (and friends) that guarantee that stdio functions like
fopen
don't reuse fd's 0, 1, or 2 (and hence that stdin, stdout, and stderr remain closed if they started life closed). I also know that gnulib provides the closeout module, which we should probably be using (and issue an error if any
output was attempted to stdout when it was already closed).

Even with my earlier patches, I'm still finding issues.  For example:

$ m4 | cat -s
divert(-1)
define(`f',`
')
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
define(`f',defn(`f')defn(`f'))
divert(1)
f
divert
syscmd(echo hi >&3)

hi

$

Oops - we didn't set the fd of our temporary file to close-on-exec, so the
child process inherited it and was able to pollute it.

--
Eric Blake















_______________________________________________
Bug-m4 mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-m4

--
Gary V. Vaughan ())_. gary@ {lilith.warpmail.net,gnu.org},address@hidden
Research Scientist   ( '/   http://blog.azazil.net
GNU Hacker           / )=   http://www.gnu.org/software/{libtool,m4}
Technical Author   `(_~)_   http://sources.redhat.com/autobook




Attachment: PGP.sig
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]