Wednesday, 15 February 2012

taint - How do I force a perl variable to always be tainted? -



taint - How do I force a perl variable to always be tainted? -

i'm looking 100% reliable solution, not dependent on input or environment or - want 100%-for-certain create scalar variable tainted :-)

i create no claims perfect reliability. 1 should create tests ensure code working expected on each new system.

however, if open file handle scalar reference, results of readline appear tainted:

#!/usr/bin/env perl -t utilize strict; utilize warnings; utilize scalar::util qw(tainted); $var = 0.13; print tainted($var) ? "yes, tainted: $var\n" : "nope, clean: $var\n"; $var = taint_string($var); print tainted($var) ? "yes, tainted: $var\n" : "nope, clean: $var\n"; sub taint_string { $value = shift; warn "not going work on references" if ref $value; open $fh, '<', \$value or die "can't open: $!"; local $/; # slurp homecoming <$fh>; }

outputs:

nope, clean: 0.13 yes, tainted: 0.13

perl taint

No comments:

Post a Comment