How to "override" a variable?

As far as I know, when a variable is corrupted, Perl will not allow it to be used on the system (), exec (), opened, eval (), the backtick command, or any function that affects something outside the program (such as unlink). So what does this mean for this?

+5
source share
2 answers

Use a regex for a corrupt variable to pull out "safe" values:

. , ; tainting . Perl , , $1, $2 .., , , .

:

, - , . , ( "" ), - . , , .

Perlsec:

+12

use Untaint:

, -T taint. CGI . , . , .

use Untaint;

my $pattern = qr(^k\w+);

my $foo = $ARGV[0];

# Untaint a scalar
if (is_tainted($foo)) {
        print "\$foo is tainted. Attempting to launder\n";
        $foo = untaint($pattern, $foo);
}else{
        print "\$foo is not tainted!!\n";
}
+6

All Articles