Subject: | remove call to eof() in _read_line() for IO::Socket::SSL compatibility |
Date: | Wed, 18 Feb 2009 17:26:56 -0500 |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Phil Lobbes <phil [...] perkpartners.com> |
With the right (or wrong) error conditions a sysread in _read_line() may
end up returning undef and the server may close the connection. The
code in _read_line() is inconsistent in handling this and in one of two
cases a call is made to $socket->eof(). Unfortunately, eof() isn't
supported with IO::Socket::SSL so a program will die with an error
similar to:
Can't locate object method "EOF" via package
"IO::Socket::SSL::SSL_HANDLE" at .../IO/Handle.pm line 393.
Below is a patch against Mail::IMAPClient 3.14 to avoid use of eof() to
preserve compatibility with IO::Socket::SSL. For your reference, there
is a similar section of code using the same logic as this patch.
Phil
$ diff -u IMAPClient.pm.ORIG IMAPClient.pm
--- IMAPClient.pm.ORIG 2009-02-16 08:15:52.000000000 -0500
+++ IMAPClient.pm 2009-02-18 15:27:13.000000000 -0500
@@ -1415,7 +1415,7 @@
return undef;
}
- if($ret==0 && $socket->eof)
+ if(defined $ret && $ret==0) # Caught EOF...
{ $self->_record($transno,
[ $self->_next_index($transno), "ERROR",
"$transno * BYE Server unexpectedly closed connection: $!"]);