DrZaius has asked for the wisdom of the Perl Monks concerning the following question:
The values I pass in are taint safe. It seems the values it pulls out of a readdir are not though, as it dies on unlinking a file in a subdirectory of the file I pass in.
Has anyone else had this problem?
Here is a simple script that also has this problem:
Do the following (on unix) to test it:#!/usr/bin/perl -wT use strict; use File::Path qw/rmtree mkpath/; rmtree(untaint_filename($ARGV[0]), 1, 1) or die "Could not rmtree $ARGV[0]: $!"; sub untaint_filename { my ($filename) = ($_[0] =~ m!^([\w\d\-_/\.]+)$!) or die "$_[0] is not safe."; return $filename; }
btw, I'm running perl 5.6.0 on linux with File::Path 1.0403mkdir -p blah/blah/blah/blah touch blah/blah/foo touch blah/blah/bar touch blah/blah/blah/foo touch blah/blah/blah/bar ./test.pl blah
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Path and Taintedness
by BMaximus (Chaplain) on Jun 23, 2001 at 04:19 UTC | |
|
Re: File::Path and Taintedness
by bikeNomad (Priest) on Jun 23, 2001 at 04:32 UTC |