Fix for
authorAndrew Pimlott <pimlott@idiomtech.com>
Wed, 4 Oct 2000 21:57:43 +0000 (17:57 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 4 Nov 2000 23:14:01 +0000 (23:14 +0000)
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

pp_hot.c
t/op/taint.t

index 3f85116..b0d53bc 100644 (file)
--- 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);
index 7cc4447..fc3a595 100755 (executable)
@@ -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";
+}