Skip to content

Commit

Permalink
Item14149: Don't crash if clamd daemon has crashed
Browse files Browse the repository at this point in the history
Failing with undefined error string if connection failed but a
stale socket existed.
  • Loading branch information
gac410 committed Sep 4, 2016
1 parent 0a9a6ee commit cf21e57
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Foswiki/Plugins/ClamAVScanPlugin/ClamAV.pm
Expand Up @@ -65,7 +65,12 @@ sub ping {

Foswiki::Func::writeDebug("Sending zPING") if TRACE;
$this->_send( $conn, "zPING\x00" );
chop( my $response = $conn->getline );
my $response = $conn->getline;
unless ( defined $response ) {
return $this->errstr("No response from !ClamAV service.");
}

chop $response;

# Run out the buffer?
1 while (<$conn>);
Expand All @@ -75,7 +80,7 @@ sub ping {
return (
$response eq "PONG"
? 1
: $this->errstr("Unknown reponse from ClamAV service: $response")
: $this->errstr("Unknown reponse from !ClamAV service: $response")
);
}

Expand Down Expand Up @@ -357,7 +362,7 @@ sub _scan_shallow {
for my $result ( $conn->getline ) {
chomp($result);
$result =~ s/\x00$//g; # remove null terminator if present;
$result = decode_utf8($result) if ( $Foswiki::UNICODE);
$result = decode_utf8($result) if ($Foswiki::UNICODE);
my ( $fn, $msg, $code ) =
$result =~ m/^(.*?):\s?(.*?)\s?(OK|ERROR|FOUND)$/;
my $fname = ( $cmd eq 'SCAN' ) ? $fn : $file;
Expand Down

0 comments on commit cf21e57

Please sign in to comment.