diff options
author | Andrew Pimlott <pimlott@idiomtech.com> | 2000-10-04 17:57:43 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-11-04 23:14:01 +0000 |
commit | 3887d568fc17eb8ca8b2dcf68e729c1ce7e5e6a5 (patch) | |
tree | 412c8a75d8bb71f9e11d2080b1c472b66b5fe941 | |
parent | b35c5fa1ef4ed5bc851a2c97d645858aa9d0f736 (diff) | |
download | perl-3887d568fc17eb8ca8b2dcf68e729c1ce7e5e6a5.tar.gz |
Fix for
Subject: [ID 20001004.006] undef is never tainted
Message-Id: <m13h0I3-000SEmC@nolfolan.idiomtech.com>
An undef read from a slurped file was not tainted.
p4raw-id: //depot/perl@7549
-rw-r--r-- | pp_hot.c | 14 | ||||
-rwxr-xr-x | t/op/taint.t | 12 |
2 files changed, 20 insertions, 6 deletions
@@ -1450,6 +1450,13 @@ Perl_do_readline(pTHX) offset = 0; } + /* This should not be marked tainted if the fp is marked clean */ +#define MAYBE_TAINT_LINE(io, sv) \ + if (!(IoFLAGS(io) & IOf_UNTAINT)) { \ + TAINT; \ + SvTAINTED_on(sv); \ + } + /* delay EOF state for a snarfed empty file */ #define SNARF_EOF(gimme,rs,io,sv) \ (gimme != G_SCALAR || SvCUR(sv) \ @@ -1478,13 +1485,10 @@ Perl_do_readline(pTHX) (void)SvOK_off(TARG); PUSHTARG; } + MAYBE_TAINT_LINE(io, sv); RETURN; } - /* This should not be marked tainted if the fp is marked clean */ - if (!(IoFLAGS(io) & IOf_UNTAINT)) { - TAINT; - SvTAINTED_on(sv); - } + MAYBE_TAINT_LINE(io, sv); IoLINES(io)++; IoFLAGS(io) |= IOf_NOLINE; SvSETMAGIC(sv); diff --git a/t/op/taint.t b/t/op/taint.t index 7cc4447a0b..fc3a595c4e 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -99,7 +99,7 @@ print PROG 'print "@ARGV\n"', "\n"; close PROG; my $echo = "$Invoke_Perl $ECHO"; -print "1..151\n"; +print "1..152\n"; # First, let's make sure that Perl is checking the dangerous # environment variables. Maybe they aren't set yet, so we'll @@ -681,3 +681,13 @@ else { } } +{ + # bug id 20001004.006 + + open IN, "./TEST" or warn "$0: cannot read ./TEST: $!" ; + local $/; + my $a = <IN>; + my $b = <IN>; + print "not " unless tainted($a) && tainted($b) && !defined($b); + print "ok 152\n"; +} |