From: Andrew Pimlott Date: Wed, 4 Oct 2000 21:57:43 +0000 (-0400) Subject: Fix for X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3887d568fc17eb8ca8b2dcf68e729c1ce7e5e6a5;p=p5sagit%2Fp5-mst-13.2.git Fix for Subject: [ID 20001004.006] undef is never tainted Message-Id: An undef read from a slurped file was not tainted. p4raw-id: //depot/perl@7549 --- diff --git a/pp_hot.c b/pp_hot.c index 3f85116..b0d53bc 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -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 7cc4447..fc3a595 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 = ; + my $b = ; + print "not " unless tainted($a) && tainted($b) && !defined($b); + print "ok 152\n"; +}