T
TechCrazy
I am writing a cgi script which will accept a regex(perl syntax) and a
string and it has to determine if the regex can generate the string.
This is what I came up with but it uses a system() on tainted data and
is not very safe against quotes. How do I get around this. Thanks a
lot, gurus.
my $text_to_be_matched = $cgi->param("text_to_be_matched") ;
my $regex = $cgi->param("regex") ;
my $cmd = "/opt/third-party/bin/perl -e \"
if (\'$text_to_be_matched\' =~ m/$regex/) {
print \'$text_to_be_matched matches $regex\' ;
}
else {
print \'$text_to_be_matched does not match
$regex\' ;
}
\"
";
print $cmd ;
system($cmd);
string and it has to determine if the regex can generate the string.
This is what I came up with but it uses a system() on tainted data and
is not very safe against quotes. How do I get around this. Thanks a
lot, gurus.
my $text_to_be_matched = $cgi->param("text_to_be_matched") ;
my $regex = $cgi->param("regex") ;
my $cmd = "/opt/third-party/bin/perl -e \"
if (\'$text_to_be_matched\' =~ m/$regex/) {
print \'$text_to_be_matched matches $regex\' ;
}
else {
print \'$text_to_be_matched does not match
$regex\' ;
}
\"
";
print $cmd ;
system($cmd);