[pmg-devel] [PATCH v2 pmg-api] fix use of uninitialized value

Mira Limbeck m.limbeck at proxmox.com
Tue Jun 18 11:26:03 CEST 2019


Return early if $info is not defined.

When moving a mail directly to quarantine without running any checks
there's no spaminfo available. As a result the value $info is undefined.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
v2:
 - exit before the expensive load_sa_descriptions call

 PMG/API2/Quarantine.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm
index a51cf1e..db1822f 100644
--- a/PMG/API2/Quarantine.pm
+++ b/PMG/API2/Quarantine.pm
@@ -57,14 +57,15 @@ my $verify_optional_pmail = sub {
 sub decode_spaminfo {
     my ($info) = @_;
 
+    my $res = [];
+    return $res if !defined($info);
+
     my $saversion = Mail::SpamAssassin->VERSION;
 
     my $salocaldir = "/var/lib/spamassassin/$saversion/updates_spamassassin_org";
 
     $spamdesc = PMG::Utils::load_sa_descriptions([$salocaldir]) if !$spamdesc;
 
-    my $res = [];
-
     foreach my $test (split (',', $info)) {
 	my ($name, $score) = split (':', $test);
 
-- 
2.11.0



More information about the pmg-devel mailing list