Baekalfen / ICAP-avscan

Uploads a file to a ICAP server.
MIT License
47 stars 28 forks source link

wrong bytes send as file data #23

Open mikolajkubi opened 4 years ago

mikolajkubi commented 4 years ago

In code of https://github.com/Baekalfen/ICAP-avscan/blob/27e147be94f4251e2f30375ec5328d721786326d/Java/ICAP/src/icap_samplecode/ICAP.java#L187 we can see this lines: while ((fileInStream.read(buffer)) != -1) { sendString(Integer.toHexString(buffer.length) +"\r\n"); sendBytes(buffer);

But method InputStream.read() may not read full buffer. This method returns the total number of bytes read into the buffer, and this value should be used in next lines. For send string and as parameter for sendBytes() call. In current state this method is sending additional bytes from buffer which were not filled by read() call.

Baekalfen commented 4 years ago

There might very well be some missing or faulty code. I haven't had access to any ICAP hardware in years, so I rely on others to make pull-requests with fixes.

lowedown commented 4 years ago

I ran into the same issue. By sending the entire buffer instead of only the remaining bytes our ICAP server didn't recognize the eicar.com testfile because it's hash was changed. Created a PR for the C# client. Someone needs to test and update this for the Java client too.