Subject: | uninitialized value in ping() |
Date: | Tue, 25 Jun 2013 17:10:41 +0000 |
To: | "bug-File-Scan-ClamAV [...] rt.cpan.org" <bug-File-Scan-ClamAV [...] rt.cpan.org> |
From: | Maarten Broekman <mbroekman [...] maileig.com> |
If the ping() function is called and is unable to get a connection to clamd, the following errors are observed:
Use of uninitialized value in scalar chomp at …File/Scan/ClamAV.pm line 140.
Use of uninitialized value in string eq at …File/Scan/ClamAV.pm line 147.
This is because $response is defined in the chomp call and no checking is done to see if it returns a defined value. The change in the return is only to add single-quotes to the error string for readability.
DIFF:
@@ -137,14 +137,16 @@
my $conn = $self->_get_connection || return;
$self->_send($conn, "PING\n");
- chomp(my $response = $conn->getline);
+ my $response = $conn->getline;
+ $response = "" if ( ! defined($response) );
+ chomp($response);
# Run out the buffer?
1 while (<$conn>);
$conn->close;
- return ($response eq 'PONG' ? 1 : $self->_seterrstr("Unknown reponse from ClamAV service: $response"));
+ return ($response eq 'PONG' ? 1 : $self->_seterrstr("Unknown reponse from ClamAV service: '$response'"));
}