File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ class ResponseError(ClamdError):
6060 pass
6161
6262
63- class BufferTooLongError (ClamdError ):
63+ class BufferTooLongError (ResponseError ):
6464 """Class for errors with clamd using INSTREAM with a buffer lenght > StreamMaxLength in /etc/clamav/clamd.conf"""
6565
6666
@@ -156,7 +156,11 @@ def _basic_command(self, command):
156156 self ._init_socket ()
157157 try :
158158 self ._send_command (command )
159- return self ._recv_response ()
159+ response = self ._recv_response ().rsplit ("ERROR" , 1 )
160+ if len (response ) > 1 :
161+ raise ResponseError (response [0 ])
162+ else :
163+ return response [0 ]
160164 finally :
161165 self ._close_socket ()
162166
@@ -290,7 +294,10 @@ def _parse_response(self, msg):
290294 """
291295 parses responses for SCAN, CONTSCAN, MULTISCAN and STREAM commands.
292296 """
293- return scan_response .match (msg ).group ("path" , "virus" , "status" )
297+ try :
298+ return scan_response .match (msg ).group ("path" , "virus" , "status" )
299+ except AttributeError :
300+ raise ResponseError (msg .rsplit ("ERROR" , 1 )[0 ])
294301
295302
296303class ClamdUnixSocket (ClamdNetworkSocket ):
You can’t perform that action at this time.
0 commit comments