[PATCH] suppress log error when $user unset

[email protected] (Matt Simerson)
Newsgroups perl.qpsmtpd
Message-ID <[email protected]>
test for and return earlier when a null sender is encountered.
Prevents using an undefined variable.
---
plugins/sender_permitted_from |   11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/plugins/sender_permitted_from b/plugins/sender_permitted_from
index 816ee20..4204b93 100644
--- a/plugins/sender_permitted_from
+++ b/plugins/sender_permitted_from
@@ -48,15 +48,14 @@ sub hook_mail {
    my ($self, $transaction, $sender, %param) = @_;

    my $format    = $sender->format;
-    my $host      = lc $sender->host;
-    my $user      = $sender->user;
+    return (DECLINED, "SPF - null sender") if $format eq '<>';
+    return (DECLINED, "SPF - null sender")
+        unless ($sender->host && $sender->user);
+
    my $client_ip = $self->qp->connection->remote_ip;
-    my $from      = $sender->user . '@' . $host;
+    my $from      = $sender->user . '@' . lc($sender->host);
    my $helo      = $self->qp->connection->hello_host;

-    return (DECLINED, "SPF - null sender")
-      unless ($format ne "<>" && $host && $user);
-
    # If we are receving from a relay permitted host, then we are probably
    # not the delivery system, and so we shouldn't check
    return (DECLINED, "SPF - relaying permitted")
-- 
1.7.9.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.