On 03/01/2010 06:39 PM, Phil Varner wrote:
> 2010/3/1 Török Edwin <[email protected]>:
>> On 03/01/2010 03:39 AM, Phil Varner wrote:
>>>             dos.writeInt(0);
>>>             dos.write('\0');
>> The write('\0') is not needed, and even wrong in IDSESSION mode, clamd
>> doesn't read it. A zero length chunk is just the chunk length as 4 bytes
>> of 0, which you already sent with writeInt.
>>
> 
> The spec in clamd man says the stream must be closed by a nul byte,
> which I thought was the reason for the z prefix?

No, it says
"It's recommended to prefix clamd commands with the letter z (eg. zSCAN)
to indicate that the command will be delim‐ited  by  a  NULL character"
"Streaming is terminated by sending a zero-length chunk"
The command was delimited by null character already: zINSTREAM\0
And the stream was terminated with zero length chunk.

> 
> --Phil
> 
> 
>>>             dos.flush();
>>>
>>>             reader = new BufferedReader(new
>>> InputStreamReader(socket.getInputStream(), "ASCII"));
>>>
>>>             response = reader.readLine();
>>>         } finally {
>>>             if (reader != null) try { reader.close(); } catch
>>> (IOException e) { }
>>>             if (dos != null) try { dos.close(); } catch (IOException e) { }
>>>             if (socket != null) try { socket.close(); } catch
>>> (IOException e) { }
>> This is not nice, your method declares that it throws IOException (which
>> it probably does for creation of socket), but then eats the other
>> IOExceptions. I think it should rethrow them instead.
>>
>>>        if (log.isDebugEnabled()) log.debug( "Response: " + response);
>>>        return response.trim();
>> And this will throw a nullpointer exception if anything goes wrong prior
>> to reading the response.
>>
>> Best regards,
>> --Edwin
>> _______________________________________________
>> Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net
>> http://www.clamav.net/support/ml
>>
> 
> 
> 

_______________________________________________
Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net
http://www.clamav.net/support/ml

Reply via email to