Skip to content

Commit 0ba6abe

Browse files
committed
Fixed potential array out of bounds exception, and an issue where we would not read the entire server response
1 parent 4ff23d3 commit 0ba6abe

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/fi/solita/clamav/ClamAVClient.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ private static byte[] readAll(InputStream is) throws IOException {
154154

155155
byte[] buf = new byte[2000];
156156
int read = 0;
157-
do {
158-
read = is.read(buf);
159-
tmp.write(buf, 0, read);
160-
} while ((read > 0) && (is.available() > 0));
157+
while ((read = is.read(buf)) != -1) {
158+
tmp.write(buf, 0, read);
159+
}
161160
return tmp.toByteArray();
162161
}
163162
}

0 commit comments

Comments
 (0)