how to untaint perl variables
variables become tainted when contain data obtained through glob(), opendir(), readdir(), etc...
to untaint path use this subroutine:
sub untaint_path
{
my $f = shift;
my $ff;
if ( $f =~ /^([\w\/\.]+)$/ ) {
$ff = $1;
}
return $ff;
}
to untaint path use this subroutine:
sub untaint_path
{
my $f = shift;
my $ff;
if ( $f =~ /^([\w\/\.]+)$/ ) {
$ff = $1;
}
return $ff;
}

1 Comments:
this also works:
sub untaint_path
{
my $f = shift;
my $ff;
if ($f =~ /^(.*)$/) {
$ff = $1;
}
return $ff;
}
Post a Comment
<< Home