From daceffa1505f7a74bd16b0a939d2c6dfd862a859 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 26 Jan 2009 16:04:03 -0800 Subject: config load: avoid possible bug in getConfigDiff The map function operates on an alias of the passed list, so any modification of the elements has bad side effects. Make an explicit copy instead: Original warning: Don't modify $_ in list functions at line 410, column 17. See page 114 of PBP. (Severity: 5) --- lib/Vyatta/ConfigLoad.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/Vyatta') diff --git a/lib/Vyatta/ConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm index 8376db4..54411ee 100755 --- a/lib/Vyatta/ConfigLoad.pm +++ b/lib/Vyatta/ConfigLoad.pm @@ -82,7 +82,7 @@ sub get_regex_rank { return $regex_rank{$_}; } } - # returns undef if no match + return; # undef if no match } sub get_config_rank { @@ -407,7 +407,12 @@ sub getConfigDiff { # need to filter out deletions of nodes with default values my @new_delete_list = (); foreach my $del (@delete_list) { - my @comps = map { s/^'(.*)'$/$1/; $_; } @{${$del}[0]}; + my @comps = map { + my $file = $_; + $file =~ s/^'(.*)'$/$1/; + $file; + } @{${$del}[0]}; + my ($is_multi, $is_text, $default) = $active_cfg->parseTmpl(\@comps); if (!defined($default)) { push @new_delete_list, $del; -- cgit v1.2.3