From 280fc68258eb39f0df4a103dc497bf56fb17e317 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sat, 2 Oct 2010 01:43:08 +0100 Subject: [PATCH] complain if files are outside $base --- bin/id3fs-index | 9 +++++++-- lib/ID3FS/DB.pm | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/id3fs-index b/bin/id3fs-index index 132d81e..93a6ebf 100755 --- a/bin/id3fs-index +++ b/bin/id3fs-index @@ -48,12 +48,17 @@ if($list) else { $db->last_update(time()); - - my $directories_pruned=$db->prune_directories(); + my $base=$db->base_dir(); + my $abs_base=Cwd::abs_path($base); while(my $path=shift) { + if(Cwd::abs_path($path) !~ /^$abs_base/) + { + print "$me, $path is outside $base, skipping\n"; + } File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path); } + my $directories_pruned=$db->prune_directories(); if($files_pruned || $directories_pruned) { print "Removing data from pruned files\n" if $verbose; diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index d149b6a..96b4f8a 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -94,6 +94,8 @@ sub find_db return $file; } +sub base_dir { return shift->{base}; } + sub create { my($self,$name)=@_; -- 2.11.0