Skip Menu |
 

This queue is for tickets about the Net-IMAP-Simple CPAN distribution.

Report information
The Basics
Id: 11874
Status: resolved
Priority: 0/
Queue: Net-IMAP-Simple

People
Owner: CFABER [...] cpan.org
Requestors: jhi [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.93
Fixed in: (no value)

Attachments


Subject: getline() can return undefined
Download (untitled) / with headers
text/plain 352b
I had some transient network outages while I was running a mailbox watcher using Net::IMAP::Simple 0.93, and the -w caught this: Use of uninitialized value in pattern match (m//) at /opt/lib/perl5/site_perl/5.8.4/Net/IMAP/Simple.pm line 428, <GEN363> line 52. The getline() had returned undef. I added a bunch of defined() checks (see attachment).
Download Simple.pm.diff
text/x-diff 3.5k
--- Simple.pm.dist Tue Mar 15 07:40:32 2005 +++ Simple.pm Tue Mar 15 07:43:33 2005 @@ -118,7 +118,7 @@ print $sh "$id LOGIN $user $pass\r\n"; $resp = $sh->getline(); - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return $self->select( 'INBOX' ); } @@ -146,7 +146,7 @@ $mbox = _escape( $mbox ); print $sh "$id SELECT $mbox\r\n"; - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*\s+(\d+)\s+EXISTS/i ) { $nmsg = $1; } elsif ( $resp =~ /^$id\s+(OK|NO|BAD)/i ) { @@ -181,7 +181,7 @@ print $sh "$id FETCH $msgn rfc822.header\r\n"; - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*/ ) { next; } @@ -219,7 +219,7 @@ print $sh "$id FETCH $msgn (FLAGS)\r\n"; - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^$id\s+(OK|NO|BAD)/i ) { last; } @@ -257,7 +257,7 @@ print $sh "$id FETCH 1:$self->{last} RFC822.SIZE\r\n"; } - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*\s+(\d+).*RFC822.SIZE\s+(\d+)/i ) { $hash->{$1} = $2; next; @@ -297,7 +297,7 @@ print $sh "$id FETCH $msgn rfc822\r\n"; - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*/ ) { next; } @@ -338,15 +338,13 @@ print $sh "$id FETCH $msgn rfc822\r\n"; - while ( $resp = $sh->getline() ) { - + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*/ ) { next; } if ( $resp =~ /^$id\s+(OK|NO|BAD)/i ) { last; } - print $fh $buffer if ( defined $buffer ); $buffer = $resp; } @@ -422,10 +420,11 @@ $id = $self->_nextid(); print $sh "$id STORE $msgn +FLAGS (\\Deleted)\r\n"; - while ( ( $resp = $sh->getline() ) && $resp !~ /^$id\s+(OK|NO|BAD)/i ) { + while ( defined ( $resp = $sh->getline() ) && + $resp !~ /^$id\s+(OK|NO|BAD)/i ) { next; } - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return 1; } @@ -451,7 +450,7 @@ $id = $self->_nextid(); print $sh "$id LIST \"\" *\r\n"; - while ( $resp = $sh->getline() ) { + while ( defined( $resp = $sh->getline() ) ) { if ( $resp =~ /^\*\s+LIST.*\s+\{\d+\}\s*$/i ) { $resp = $sh->getline(); chomp( $resp ); @@ -500,7 +499,7 @@ print $sh "$id CREATE $mbox_name\r\n"; $resp = $sh->getline(); - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return 1; } @@ -529,7 +528,7 @@ print $sh "$id DELETE $mbox_name\r\n"; $resp = $sh->getline(); - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return 1; } @@ -559,7 +558,7 @@ print $sh "$id RENAME $mbox_name $new_name\r\n"; $resp = $sh->getline(); - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return 1; } @@ -588,7 +587,7 @@ print $sh "$id COPY $msgn $mbox_name\r\n"; $resp = $sh->getline(); - if ( $resp =~ /^$id\s+OK/i ) { + if ( defined $resp && $resp =~ /^$id\s+OK/i ) { return 1; }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.