[patch: perl@8211]VMS: add -Duseperlio capacity to configure.com
[p5sagit/p5-mst-13.2.git] / t / op / taint.t
index af57834..1e3d396 100755 (executable)
@@ -9,7 +9,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib' if -d '../lib';
+    @INC = '../lib';
 }
 
 use strict;
@@ -99,7 +99,7 @@ print PROG 'print "@ARGV\n"', "\n";
 close PROG;
 my $echo = "$Invoke_Perl $ECHO";
 
-print "1..151\n";
+print "1..155\n";
 
 # First, let's make sure that Perl is checking the dangerous
 # environment variables. Maybe they aren't set yet, so we'll
@@ -618,8 +618,8 @@ else {
        my $sent = "foobar";
        my $rcvd;
        my $size = 2000;
-       my $id = shmget(IPC_PRIVATE, $size, S_IRWXU) ||
-           warn "# shmget failed: $!\n";
+       my $id = shmget(IPC_PRIVATE, $size, S_IRWXU);
+
        if (defined $id) {
            if (shmwrite($id, $sent, 0, 60)) {
                if (shmread($id, $rcvd, 0, 60)) {
@@ -630,7 +630,7 @@ else {
            } else {
                warn "# shmwrite failed: $!\n";
            }
-           shmctl($id, IPC_RMID, 0) || warn "# shmctl failed: $!\n";
+           shmctl($id, IPC_RMID, 0) or warn "# shmctl failed: $!\n";
        } else {
            warn "# shmget failed: $!\n";
        }
@@ -666,7 +666,7 @@ else {
            } else {
                warn "# msgsnd failed\n";
            }
-           msgctl($id, IPC_RMID, 0) || warn "# msgctl failed: $!\n";
+           msgctl($id, IPC_RMID, 0) or warn "# msgctl failed: $!\n";
        } else {
            warn "# msgget failed\n";
        }
@@ -681,3 +681,42 @@ 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";
+    close IN;
+}
+
+{
+    # bug id 20001004.007
+
+    open IN, "./TEST" or warn "$0: cannot read ./TEST: $!" ;
+    my $a = <IN>;
+
+    my $c = { a => 42,
+             b => $a };
+    print "not " unless !tainted($c->{a}) && tainted($c->{b});
+    print "ok 153\n";
+
+    my $d = { a => $a,
+             b => 42 };
+    print "not " unless tainted($d->{a}) && !tainted($d->{b});
+    print "ok 154\n";
+
+    my $e = { a => 42,
+             b => { c => $a, d => 42 } };
+    print "not " unless !tainted($e->{a}) &&
+                       !tainted($e->{b}) &&
+                        tainted($e->{b}->{c}) &&
+                       !tainted($e->{b}->{d});
+    print "ok 155\n";
+
+    close IN;
+}
+