]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #4269: rule cache: from match: cope with undefined IP
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 1 Oct 2022 09:56:40 +0000 (11:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 1 Oct 2022 10:01:55 +0000 (12:01 +0200)
No semantic change, just avoids an ugly warning. Can normally only
happen if a mail is send/inject directly from the PMG host.

fwiw, all the rule implementation that actually use $ip got an early
return 0 if $ip evaluates to false(y), one might actually consider
checking the counterpart too for false-y in this case, and return a
match if both are false (or maybe better, make the check a
definedness one); but as this is for an edge case we might just keep
it as is for now, worked ok for more than a decade..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/RuleCache.pm

index 655f4a2cf2f193d3ff242afe07cd8cf5d9050bf8..d35e9c1b1b7f9099b22a14983eee7d2446d9391b 100644 (file)
@@ -242,7 +242,7 @@ sub from_match {
     return 1 if !defined ($from);
 
     # postfix prefixes ipv6 addresses with IPv6:
-    if ($ip =~ /^IPv6:(.*)/) {
+    if (defined($ip) && $ip =~ /^IPv6:(.*)/) {
        $ip = $1;
     }