bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macr


From: Andrew J. Schorr
Subject: Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro
Date: Tue, 15 Apr 2014 10:13:54 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Apr 15, 2014 at 01:49:56PM +0100, Dave Sines wrote:
> And while your suggestion works,
> 
>   $ ./gawk '{ print }' /./inet/.mounted
>   $ ./gawk 'BEGIN { f = "/./inet/.mounted" ; getline < f }'
>   $ 
> 
> Ensuring that gawk never receives a filename beginning with "/inet/"
> (including indirectly in shell scripts) is impractical on a system with
> an existing /inet.

Fair enough.  I have 2 thoughts regarding this:

1. It is sufficient to say //inet/.mounted in order to fail the tests in
io.c:inetfile() and thus be treated as a normal file.

2. Would it make sense simply to enhance the parsing in io.c:inetfile()
to test more than the filename prefix before deciding that it is a
special socket file?  The full syntax for a special file is:
   /NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT

Currently, io.c:inetfile() tests only whether the prefix is
"/inet/" or "/inet4/" or "/inet6/" to decide whether it's a special
socket file.  Should we do more parsing in that function and treat
files as regular unless they match the full specification?  While there
still could be problems, it seems fairly unlikely that a regular filename
would collide with the full socket syntax.

The only downside I see is that if somebody enters a socket-style name
incorrectly, it might be treated as a regular file instead of giving an error
such as "special file name `%s' is incomplete".

Thoughts?

Regards,
Andy



reply via email to

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