I have a function like this:
open my $pipe, "-|", '/usr/bin/externalcmd | /usr/bin/awk \'{print $2" "$4}\''
|| die "can't fork command: $!";
while (<$pipe>) {
my ($if, $ip) = split;
my $file = "/some/file/$if";
open (FILE, ">$file") || die "can't open $file for $ip: $!";
# ...
close(FILE);
}
close ($pipe);
It fails on open with the following error:
Insecure dependency in open while running with -T switch at line 1383, <$pipe> line 1.
How can I fix this?
The answer was to "launder" the $if variable through a regex match like this:
# e.g., only "word" characters
if ($if =~ /^([-\@\w.]+)\z/) {
$if = $1;
} else {
die "Bad data in '$if'";
}
Then proceed as before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With