develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #117265] [PATCH] e213661 no warnings 'safesyscalls', fatal nul checks

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
July 17, 2013 02:12
Subject:
[perl #117265] [PATCH] e213661 no warnings 'safesyscalls', fatal nul checks
Message ID:
rt-3.6.HEAD-2552-1374027163-293.117265-15-0@perl.org
On Sat Jul 06 16:10:49 2013, perl.p5p@rjbs.manxome.org wrote:
> * Father Chrysostomos via RT <perlbug-followup@perl.org> [2013-06-
> 28T02:56:27]
> > And mine, too.  Just to be clear, in case we misunderstand each
> other,
> > that means no warnings, just a failed system call, which will be
> > detected by the existing error checking code.  (You *do* check the
> > return values of your system calls, right? :-)
> 
> Exactamo.
> 
> Here is the only thing that gives me a little pause:  I check those
> return
> values and say something like:
> 
>   open ... or die "couldn't open <$filename>: $!";
> 
> And if $filename is "foo.txt\0" then the error message is confusing...
> ...but I don't think it would be in practice, because trailing NULs
> are just
> ignored, rather than cause for a ENOENT.  They're used in 2-arg open
> to
> clear up ambiguity with files ending in a pipe, and we can keep
> allowing and
> ignoring them.  In any other case, the error message will contain non-
> nuls
> after the nuls, and we're good.  (In the unlikely event of $realname .
> $nul .
> $zerowidth, well, the programmer will have to debug.)

The warning would help in diagnosing this.

I'm considering the following changes before applying this:

- modify the CHECK_SAFESYSCALLS/CHECK_PATHNAME macros to only check the
path name and optionally warn, rather than hiding the control flow for
the function return (this may need a helper function)

- make the warning off by default, but can be enabled explicitly with
use warnings 'safesyscalls';

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=117265

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About