about summary refs log tree commit
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2014-12-09 13:45:02 +0000
committerSteve Hay <steve.m.hay@googlemail.com>2014-12-09 13:45:02 +0000
commit56e5ec7a786f0a0b5c95f017285b8b9791de068a (patch)
treeca0a70dcc84691785eb3bd2a15e416b354837982
parent205a35884f210a3ca8afc01a9a195b173f329466 (diff)
downloadperl-libnet-56e5ec7a786f0a0b5c95f017285b8b9791de068a.tar.gz
last does not work in a do {} block
There is no point in continuing with the auth() function if there are no
mechanisms left to try (it would only issue an AUTH command with no
arguments, which is a syntax error) so simply return instead of trying to
jump out of the do {} block.

Also return if we cannot get the failed mechanism from the client because
in that case we have no way of changing the list of mechanisms to try.

Partially fixes CPAN RT#100235.
-rw-r--r--Changes2
-rw-r--r--lib/Net/SMTP.pm3
2 files changed, 3 insertions, 2 deletions
diff --git a/Changes b/Changes
index b1c737b..8928e1d 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,7 @@ Revision history for Perl distribution libnet
 
 3.05 Development
 
-    - TODO
+    - Fixed infinite loop in Net::SMTP::auth().  [CPAN RT#100235]
 
 3.04 2014-11-29
 
diff --git a/lib/Net/SMTP.pm b/lib/Net/SMTP.pm
index 57f51cc..afd017a 100644
--- a/lib/Net/SMTP.pm
+++ b/lib/Net/SMTP.pm
@@ -193,10 +193,11 @@ sub auth {
     if ($client) {
       # $client mechanism failed, so we need to exclude this mechanism from list
       my $failed_mechanism = $client->mechanism;
+      return unless defined $failed_mechanism;
       $self->debug_text("Auth mechanism failed: $failed_mechanism")
         if $self->debug;
       $mechanisms =~ s/\b\Q$failed_mechanism\E\b//;
-      last unless $mechanisms =~ /\S/;
+      return unless $mechanisms =~ /\S/;
       $sasl->mechanism($mechanisms);
     }