From 3ac7db8b6b470db371db98ca3da5ec523909b13d Mon Sep 17 00:00:00 2001 From: John Southworth Date: Mon, 25 Apr 2011 11:18:08 -0500 Subject: Check the validity of the filename passed to the image-tools script --- scripts/vyatta-image-tools.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl index f19e18d..51c8d97 100755 --- a/scripts/vyatta-image-tools.pl +++ b/scripts/vyatta-image-tools.pl @@ -32,11 +32,18 @@ if (@copy){ sub conv_file { my $file = " "; - $file = pop(@_); - $file =~ s/://; - $file =~ /(.+?)\/\/(.*)/; - my $topdir = $1; - $file = $2; + my $filein = pop(@_); + $file = $filein; + my $topdir; + if ($file =~ /(.+?):\/\/(.*)/){ + $topdir = $1; + $file = $2; + } elsif ($file =~ /^\//) { + $topdir = "running"; + } else { + print "File not found \n"; + exit 1; + } if ( $topdir eq "running" ) { $file = "/$file"; } else { @@ -145,7 +152,7 @@ sub show { system("file -sb $file"); print "\n########### FILE DATA ###########\n"; system("cat $file"); - } elsif ( $file =~ /.*\.pcap/ ){ + } elsif ( $file =~ /.*\.pcap/ ){ print "########### FILE INFO ###########\n"; my $filename = conv_file_to_rel($topdir, $file); print "File Name: $filename\n"; -- cgit v1.2.3