break;
case 't':
- PL_taint_warn = TRUE;
- if (! (PL_dowarn & G_WARN_ALL_MASK))
- PL_dowarn |= G_WARN_ON;
+ if( !PL_tainting ) {
+ PL_taint_warn = TRUE;
+ PL_tainting = TRUE;
+ }
+ s++;
+ goto reswitch;
case 'T':
PL_tainting = TRUE;
+ PL_taint_warn = FALSE;
s++;
goto reswitch;
char *popt = s;
while (isSPACE(*s))
s++;
- if (*s == '-' && *(s+1) == 'T')
+ if (*s == '-' && *(s+1) == 'T') {
PL_tainting = TRUE;
+ PL_taint_warn = FALSE;
+ }
else {
char *popt_copy = Nullch;
while (s && *s) {
}
}
if (*d == 't') {
- PL_tainting = TRUE;
- PL_taint_warn = TRUE;
+ if( !PL_tainting ) {
+ PL_taint_warn = TRUE;
+ PL_tainting = TRUE;
+ }
} else {
moreswitches(d);
}
}
}
+ if (PL_taint_warn && PL_dowarn != G_WARN_ALL_OFF) {
+ PL_compiling.cop_warnings = newSVpvn(WARN_TAINTstring, WARNsize);
+ }
+
if (!scriptname)
scriptname = argv[0];
if (PL_e_script) {
return s;
case 'W':
PL_dowarn = G_WARN_ALL_ON|G_WARN_ON;
+ if (!specialWARN(PL_compiling.cop_warnings))
+ SvREFCNT_dec(PL_compiling.cop_warnings);
PL_compiling.cop_warnings = pWARN_ALL ;
s++;
return s;
case 'X':
PL_dowarn = G_WARN_ALL_OFF;
+ if (!specialWARN(PL_compiling.cop_warnings))
+ SvREFCNT_dec(PL_compiling.cop_warnings);
PL_compiling.cop_warnings = pWARN_NONE ;
s++;
return s;
=item B<-t>
Like B<-T>, but taint checks will issue warnings rather than fatal
-errors. Also, all warnings are turned on as if you had used also
-a B<-w>.
+errors. These warnings can be controlled normally with C<no warnings
+qw(taint)>.
B<NOTE: this is not a substitute for -T.> This is meant only to be
used as a temporary development aid while securing legacy code:
PL_compiling.cop_warnings = pWARN_ALL ;
else if (PL_dowarn & G_WARN_ALL_OFF)
PL_compiling.cop_warnings = pWARN_NONE ;
+ else if (PL_taint_warn)
+ PL_compiling.cop_warnings = newSVpvn(WARN_TAINTstring, WARNsize);
else
PL_compiling.cop_warnings = pWARN_STD ;
SAVESPTR(PL_compiling.cop_io);
-#!./perl -tw
+#!./perl -t
BEGIN {
chdir 't';
require './test.pl';
}
-plan tests => 10;
+plan tests => 11;
my $Perl = which_perl();
like( $warning, qr/^Insecure dependency in unlink $Tmsg/,
'unlink() taint warn' );
ok( !-e $file, 'unlink worked' );
+
+ok( !$^W, "-t doesn't enable regular warnings" );
#define WARNsize 12
#define WARN_ALLstring "\125\125\125\125\125\125\125\125\125\125\125\125"
#define WARN_NONEstring "\0\0\0\0\0\0\0\0\0\0\0\0"
+#define WARN_TAINTstring "\0\0\0\0\0\0\0\0\0\20\0\0"
#define isLEXWARN_on (PL_curcop->cop_warnings != pWARN_STD)
#define isLEXWARN_off (PL_curcop->cop_warnings == pWARN_STD)
###########################################################################
-sub mkHex
+sub mkHexOct
{
- my ($max, @a) = @_ ;
+ my ($f, $max, @a) = @_ ;
my $mask = "\x00" x $max ;
my $string = "" ;
vec($mask, $_, 1) = 1 ;
}
- #$string = unpack("H$max", $mask) ;
- #$string =~ s/(..)/\x$1/g;
foreach (unpack("C*", $mask)) {
- $string .= '\x' . sprintf("%2.2x", $_) ;
+ if ($f eq 'x') {
+ $string .= '\x' . sprintf("%2.2x", $_)
+ }
+ else {
+ $string .= '\\' . sprintf("%o", $_)
+ }
}
return $string ;
}
+sub mkHex
+{
+ my($max, @a) = @_;
+ return mkHexOct("x", $max, @a);
+}
+
+sub mkOct
+{
+ my($max, @a) = @_;
+ return mkHexOct("o", $max, @a);
+}
+
###########################################################################
if (@ARGV && $ARGV[0] eq "tree")
#print WARN tab(5, '#define WARN_ALLstring'), '"', ('\377' x $warn_size) , "\"\n" ;
print WARN tab(5, '#define WARN_ALLstring'), '"', ('\125' x $warn_size) , "\"\n" ;
print WARN tab(5, '#define WARN_NONEstring'), '"', ('\0' x $warn_size) , "\"\n" ;
+my $WARN_TAINTstring = mkOct($warn_size, map $_ * 2, @{ $list{'taint'} });
+
+print WARN tab(5, '#define WARN_TAINTstring'), qq["$WARN_TAINTstring"\n] ;
print WARN <<'EOM';