X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=contrib%2Frestore.pl;h=40ac46909da1efb9549acd51fb1a9ebe1cf6f263;hb=fae5b159f9526d9903121fea3d5da7ba4b4ba73b;hp=f9c55ce06320dbe63e7434661819a59ae3e7ac12;hpb=ab51d5778a1f19c204c935de231737df2e62c20c;p=cumulus.git diff --git a/contrib/restore.pl b/contrib/restore.pl index f9c55ce..40ac469 100755 --- a/contrib/restore.pl +++ b/contrib/restore.pl @@ -122,17 +122,21 @@ sub load_ref { # If a range was specified, then only a subset of the bytes of the object # are desired. Extract just the desired bytes. if ($range) { - if ($range !~ m/^\[((\d+)\+)?(\d+)\]$/) { - die "Malformed object range: $range"; - } - my $object_size = length $contents; my ($start, $length); - if ($1 ne "") { - ($start, $length) = ($2 + 0, $3 + 0); + + if ($range =~ m/^\[=(\d+)\]$/) { + die "Object size incorrect (ref $ref_str, actual size $object_size" + if $object_size != $1; + ($start, $length) = (0, $1 + 0); + } elsif ($range =~ m/^\[(\d+)\]$/) { + ($start, $length) = (0, $1 + 0); + } elsif ($range =~ m/^\[(\d+)\+(\d+)\]$/) { + ($start, $length) = ($1 + 0, $2 + 0); } else { - ($start, $length) = (0, $3 + 0); + die "Malformed object range: $range"; } + if ($start >= $object_size || $start + $length > $object_size) { die "Object range $range falls outside object bounds " . "(actual size $object_size)"; @@ -359,7 +363,7 @@ sub process_metadata { # Try to parse the data as "key: value" pairs of file metadata. Also # handle continuation lines, which start with whitespace and continue # the previous "key: value" pair. - if ($line =~ m/^(\w+):\s*(.*)$/) { + if ($line =~ m/^([-\w]+):\s*(.*)$/) { $info{$1} = $2; $last_key = $1; } elsif ($line =~/^\s/ && defined $last_key) { @@ -409,7 +413,7 @@ while (defined($line = )) { # lines. chomp $line; - if ($line =~ m/^(\w+):\s*(.*)$/) { + if ($line =~ m/^([-\w]+):\s*(.*)$/) { $descriptor{$1} = $2; $last_key = $1; } elsif ($line =~/^\s/ && defined $last_key) {