bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: igawk unsafe temporary file handling


From: solar
Subject: Re: igawk unsafe temporary file handling
Date: Mon, 28 May 2001 04:02:10 +0400
User-agent: Mutt/1.2.5i

On Sun, May 27, 2001 at 01:11:47PM -0700, Paul Eggert wrote:
> > From: address@hidden
> > Date: Sun, 27 May 2001 05:30:50 +0400
> > 
> > igawk from gawk-3.0.6 creates its temporary files unsafely.
> > 
> > The attached patch is based on report and an older patch from
> > Jarno Huuskonen <address@hidden>.  The patch requires
> > mktemp and thus isn't very portable.
> 
> How about the following patch instead?  It works around the problem by
> avoiding temporary files entirely.  I found a few other bugs and

This sounds good, but I'm not sure will work everywhere (see below).

> portability problems in igawk and fixed them too, while I was at it.

Great.

What I don't understand is why this needs to be a shell script at all,
why not implement the entire igawk in awk?

> +processed_program=`gawk -- "$process_include_directives" /dev/stdin <<EOF

Is /dev/stdin sufficiently portable?  Even on Linux it requires
procfs, which means igawk won't work in some chroot environments.

$process_include_directives I think is small enough, should be under
one page.

> +$program
> +EOF

I suspect some shells may have low limits on the size of variables.
I don't know of any examples, though.

bash has large overhead when storing variables in memory (a 10 MB
variable causes bash to consume 50 MB address space / 36 MB RSS),
but hopefully igawk programs aren't that large.

> +eval gawk $opts -- '"$processed_program"' 'address@hidden"$@@"@}'

Now this is limited by the kernel.  Linux allows for up to 32 pages
for argv[] + envp[] (128 KB on x86), but some other systems have a
lower limit, possibly as low as one page.  You need to find a way to
write this differently, without using the command line.

-- 
/sd



reply via email to

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