Andre_br has asked for the wisdom of the Perl Monks concerning the following question:
I am in need of thy help!
I have just activated the -T switch in all my scripts and everything went smoothly untill I run into the "unlink" command. He seems not to accept my untainting regexp, complaining "Insecure dependency in unlink while running with -T switch...". Here goes my code:
Hereīs the untaint() function, wich is 'require'd from another .cgi:my $subcookie = untaint ( substr($cookie,0,6) ); # this is a substring + of the SID, that I use as a name for a dinamic directory for the use +r. Also, check my untaint() function below opendir (DIR, "../users/$subcookie/"); # I was using glob, but couldnī +t make -T accept it, so I changed to readdir my @files = readdir DIR; foreach my $file (@files) { my $checked_file; if ( $file =~ /(\w+)\.(\w{3,4})/ ) { $checked_file = "$1.$2"; } # a +voiding the first "." and ".." thar readdir returns if ( defined $checked_file ) { unlink "../users/$subcookie/$checked +_file"; } } close DIR; ... # and the code goes on
Anyone knows what might be? Is there a less demanding function I can use to wipe out all the files in this directory?sub untaint { my $string = shift; my $clean_string; if ( $string =~ /([\w\-\_]+)/ ) { $clean_string = $1; } else { die "ilegal character: $!"; } return $clean_string; }
Thanks a lot, my friends!
André
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unlink under taint mode
by tlm (Prior) on Apr 10, 2005 at 01:48 UTC | |
by tlm (Prior) on Apr 10, 2005 at 02:31 UTC | |
|
Re: Unlink under taint mode
by Zaxo (Archbishop) on Apr 10, 2005 at 09:52 UTC | |
by tlm (Prior) on Apr 10, 2005 at 15:16 UTC | |
|
Re: Unlink under taint mode
by tlm (Prior) on Apr 10, 2005 at 16:26 UTC | |
by Andre_br (Pilgrim) on Apr 12, 2005 at 00:37 UTC |