Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IndexOutOfBoundsException #14

Open
julius-d opened this issue Apr 8, 2019 · 2 comments
Open

java.lang.IndexOutOfBoundsException #14

julius-d opened this issue Apr 8, 2019 · 2 comments

Comments

@julius-d
Copy link

julius-d commented Apr 8, 2019

Hi!

If I run multiple scans or pings in parallel I get this error

java.lang.IndexOutOfBoundsException: Range [0, 0 + -1) out of bounds for length 2000
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromIndexSize(Preconditions.java:82) ~[na:na]
	at java.base/jdk.internal.util.Preconditions.checkFromIndexSize(Preconditions.java:343) ~[na:na]
	at java.base/java.util.Objects.checkFromIndexSize(Objects.java:424) ~[na:na]
	at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:155) ~[na:na]
	at fi.solita.clamav.ClamAVClient.readAll(ClamAVClient.java:159) ~[clamav-client-1.0.1.jar!/:na]
	at fi.solita.clamav.ClamAVClient.scan(ClamAVClient.java:111) ~[clamav-client-1.0.1.jar!/:na]
	at fi.solita.clamav.ClamAVClient.scan(ClamAVClient.java:124) ~[clamav-client-1.0.1.jar!/:na]

The bad thing is that after this error occured the whole anti virus scanner is not responding any longer.

BR

@drogin
Copy link
Contributor

drogin commented Aug 9, 2019

I've found a situation where an IndexOutOfBoundsException could happen, but I struggle to see how it would cause the entire scanner to stop responding for other requests. Are you certain it's not at your end it stops due to parallel thread management? Anyway, I will submit a pull request for the IndexOutOfBoundsException bug

@akozmic-prisidio
Copy link

akozmic-prisidio commented Oct 13, 2021

EDIT: Looks like Docker locally was capped at 2GB and its a well-known issue with ClamAV that it can be a memory-hog with clamd and freshclam running. Running netstat on the box def showed that after the database was updated, the socket would die. Upped it to 8GB and 🤞 so far so good.

I am getting a similar issue even when running the code in serial. I'm running the clamav docker container and forwarding the Host port 9999 to 3310 via

docker run -p 9999:3310 clamav/clamav

When the container spins up, the console writes
Socket for clamd not found yet, retrying (X/1800).
After about 20 tries, it says
socket found. clamd started.

As soon as that happens I can run the code and everything works correctly. I created the 'eicar.com' file locally as well as another test file and I can use this library to process both files via "localhost" and port 9999 on my local machine. I have successfully ran 1000 individual trials.

On every trial of the test virus file (eicar.com), the console writes
Wed Oct 13 15:44:48 2021 -> instream(172.17.0.1@63548): Win.Test.EICAR_HDB-1 FOUND

Shortly after all this success, the freshclam process picks up the database updates on the clamav container and the console reads
Clamd successfully notified about the update.

After this occurs, I continuously get the exception
java.lang.IndexOutOfBoundsException: Range [0, 0 + -1) out of bounds for length 2000
and never see the Win.Test.EICAR_HDB-1 FOUND message on the console.

I don't know if this is an issue with this library, the clamav docker container, clamd, freshclam, or what. Interestingly enough I get the exact same results using the Capybara library as well, which makes me think its something with clamd and the database update via freshclam. I will continue to dig but wanted to put the details here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants