summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-04-25 11:18:08 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-04-25 11:18:08 -0500
commit3ac7db8b6b470db371db98ca3da5ec523909b13d (patch)
tree0f3b41ff55e9177a35882f64c16d544a1a687c45
parent753e1a7c79df5e2766cd6fa807078c8e0f68c05e (diff)
downloadvyatta-op-3ac7db8b6b470db371db98ca3da5ec523909b13d.tar.gz
vyatta-op-3ac7db8b6b470db371db98ca3da5ec523909b13d.zip
Check the validity of the filename passed to the image-tools script
-rwxr-xr-xscripts/vyatta-image-tools.pl19
1 files 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";