In realpath(), make sure each path component consists only of safe

characters, and untaint it.
This commit is contained in:
Dag-Erling Smørgrav 2005-07-29 11:28:03 +00:00
parent 614232077b
commit 8b4c82b30e

View File

@ -91,7 +91,9 @@ sub realpath($;$) {
or die("unable to resolve symlink '$realpath/$part': $!\n");
$realpath = realpath($target, $realpath);
} else {
$realpath .= "/$part";
$part =~ m/^([\w.-]+)$/
or die("unsafe path '$realpath/$part'\n");
$realpath .= "/$1";
}
}
return $realpath;