From 37b30caeb2d7913fc0b7ee4f7bdb7c2e550e8b85 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sat, 14 Dec 2019 17:06:15 +0100 Subject: [PATCH] btrbk: bugfix: vinfo_match: skip match against invalid paths Dont check url_regex if $vinfo->{URL} is not a valid path (e.g. when checking against a "volume" or "subvolume" having wildcards): "Use of uninitialized value in join or string" at line 3030 --- btrbk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/btrbk b/btrbk index c80491a..369da9f 100755 --- a/btrbk +++ b/btrbk @@ -3027,7 +3027,11 @@ sub vinfo_match($$;@) my $vinfo = shift; my %opts = @_; my $flag_matched = $opts{flag_matched}; - my $url = join("", check_url($vinfo->{URL})); # sanitize URL (can contain "//", see vinfo_child) + + # match URL against sane path (can contain "//", see vinfo_child), + # no wildcards + my ($url_prefix, $path) = check_url($vinfo->{URL}); + my $url = defined($path) ? $url_prefix . $path : undef; my $count = 0; foreach my $ff (@$filter) { if(defined($ff->{group_eq}) && (grep { $ff->{group_eq} eq $_ } @{$vinfo->{CONFIG}{group}})) { @@ -3037,7 +3041,7 @@ sub vinfo_match($$;@) $ff->{$flag_matched} = 1; $count++; } - if(defined($ff->{url_regex}) && ($url =~ /$ff->{url_regex}/)) { + if(defined($ff->{url_regex}) && defined($url) && ($url =~ /$ff->{url_regex}/)) { TRACE "filter \"$ff->{unparsed}\" matches $vinfo->{CONFIG}{CONTEXT} url: $vinfo->{PRINT}"; return $ff unless($flag_matched); #push @{$ff->{$flag_matched}}, $vinfo->{CONFIG}{CONTEXT} . '=' . $vinfo->{PRINT};