From 78c3f75328bcdd3f0129953b3bb0cd6e99f36395 Mon Sep 17 00:00:00 2001 From: hjp Date: Mon, 25 Feb 2002 23:33:29 +0000 Subject: [PATCH] Applied patch from "Chris L. Mason" to prevent filesystem traversal. Return immediately if we cannot chdir back to the directory we came from. --- cleandir/cleandir.pl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cleandir/cleandir.pl b/cleandir/cleandir.pl index df753db..8467835 100755 --- a/cleandir/cleandir.pl +++ b/cleandir/cleandir.pl @@ -23,12 +23,18 @@ sub cleandir { return; } my $std = lstat("."); + my $fs = $std->dev; + for my $i (readdir(DIR)) { if ($i eq "." || $i eq "..") {next} if ($verbose > 2) { print STDERR "$0:", " " x $level, " checking $dir/$i\n"; } my $st = lstat("$i"); + + # Skip anything on a different filesystem + next if ($st->dev != $fs); + if ($verbose > 3) { print STDERR "$0:", " " x $level, " mtime=", $st->mtime, " atime=", $st->atime, "\n"; } @@ -56,6 +62,7 @@ sub cleandir { " to ", $std1->dev, "/", $std1->ino, "\n"; + return ++$notremoved; } if ($remaining == 0 && $st->mtime < $since) { if ($verbose > 0) { @@ -113,7 +120,14 @@ sub main { main(); # $Log: cleandir.pl,v $ -# Revision 1.1 2001-06-25 17:55:03 hjp +# Revision 1.2 2002-02-25 23:33:29 hjp +# Applied patch from "Chris L. Mason" to prevent +# filesystem traversal. +# +# Return immediately if we cannot chdir back to the directory we came +# from. +# +# Revision 1.1 2001/06/25 17:55:03 hjp # Added configure script to figure out perl location. # # Revision 1.4 2000/11/20 21:10:08 hjp