Summary: | app-portage/cfg-update-1.8.9-r1: uninitialized value $md5sum_file | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Phil Stracchino (Unix Ronin) <phils> |
Component: | Current packages | Assignee: | Richard Freeman <rich0> |
Status: | UNCONFIRMED --- | ||
Severity: | normal | CC: | kingjon3377, phils |
Priority: | Normal | Keywords: | PATCH |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | CORRECTED patch for uninitialized $md5sum_file |
Description
Phil Stracchino (Unix Ronin)
2021-12-26 05:26:11 UTC
(A simple fix would be to initialize $md5sum_file to an empty string when it is declared.) Still present in 1.8.9-r2 The fundamental problem here is that sub determine_state{} checks that $file1 exists before trying to calculate its md5sum, but then blindly goes on to use the uninitialized md5sum ANYWAY if it doesn't. Try this one-line fix: minbar:root:~:9 # diff -U5 /usr/bin/cfg-update /usr/bin/cfg-update.old --- /usr/bin/cfg-update 2022-06-25 16:47:50.023193830 -0400 +++ /usr/bin/cfg-update.old 2022-04-23 13:12:25.109290952 -0400 @@ -995,11 +995,11 @@ if ($opt_d >= 1) { print "$tab"." grep \"$file1_without_host \" $host_path$index_file $debug | cut -d\" \" -f2 $debug\n"; } local $ENV{LC_ALL}="C"; chomp ($md5sum_index = `grep "$file1_without_host " "$host_path$index_file" $debug | cut -d" " -f2 $debug`); if ($opt_d >= 1) { print "$tab"." MD5 checksum in the checksum-index : $md5sum_index\n"; } if ($md5sum_index =~ /.+/) { - if (length($md5sum_file) && $md5sum_index !~ $md5sum_file) { + if ($md5sum_index !~ $md5sum_file) { $state = $state1; $vstate = $vstate1; # 1 = MF = Modified File - checksum differs from index if (-B "$file1") { $state = $state2; $vstate = $vstate2; } # 2 = MB = Modified Binary - you probably replaced the binary file so replace not allowed } else { $state = $state3; $vstate = $vstate3; # 3 = UF = Unmodified File - checksum matches with index if (-B "$file1") { $state = $state4; $vstate = $vstate4; } # 4 = UB = Unmodified Binary - unmodified binary file so replace always allowed (In reply to Phil Stracchino (Unix Ronin) from comment #2) > Still present in 1.8.9-r2 > - if (length($md5sum_file) && $md5sum_index !~ $md5sum_file) { > + if ($md5sum_index !~ $md5sum_file) { To my significant embarrassment, NOT UNTIL TODAY when the issue resurfaced after a rebuild did I notice that my patch above is reversed. Oops. Created attachment 892831 [details, diff]
CORRECTED patch for uninitialized $md5sum_file
Same patch, just it's the right way round this time.
|