You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/04/01 16:56:13 UTC

[tika] branch master updated: TIKA-3080 -- prevent infinite loop in CharsetMatch.getString

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e33e28  TIKA-3080 -- prevent infinite loop in CharsetMatch.getString
8e33e28 is described below

commit 8e33e28b72b791710a1e9fdf515c2fcd72f82deb
Author: tallison <ta...@apache.org>
AuthorDate: Wed Apr 1 12:55:46 2020 -0400

    TIKA-3080 -- prevent infinite loop in CharsetMatch.getString
---
 tika-parsers/src/main/java/org/apache/tika/parser/txt/CharsetMatch.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/txt/CharsetMatch.java b/tika-parsers/src/main/java/org/apache/tika/parser/txt/CharsetMatch.java
index 06ff848..c256cac 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/txt/CharsetMatch.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/txt/CharsetMatch.java
@@ -144,7 +144,7 @@ public class CharsetMatch implements Comparable<CharsetMatch> {
             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;
             }