Skip to content

Commit

Permalink
TIKA-3080 -- prevent infinite loop in CharsetMatch.getString
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Apr 1, 2020
1 parent aaa9f40 commit 8e33e28
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public String getString(int maxLength) throws java.io.IOException {
int max = maxLength < 0 ? Integer.MAX_VALUE : maxLength;
int bytesRead = 0;

while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) >= 0) {
while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) > 0) {
sb.append(buffer, 0, bytesRead);
max -= bytesRead;
}
Expand Down

0 comments on commit 8e33e28

Please sign in to comment.