Skip to content

Commit

Permalink
Properly compute the safe read limit when multiplying by 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmiaw committed May 9, 2018
1 parent b0fdc65 commit f63fc6d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/com/netflix/msl/io/ThriftyUtf8Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ public void mark(final int readLimit) throws IOException {
// This is complicated because the read limit is in characters but the
// backing input stream is in bytes. If we really want to be safe then
// we need to multiply by 4 bytes. Account for overflow.
final int safeLimit = Math.max(Integer.MAX_VALUE, 4 * readLimit);
final int byteLimit = 4 * readLimit;
final int safeLimit = (byteLimit < 0) ? Integer.MAX_VALUE : byteLimit;
fInputStream.mark(safeLimit);
}

Expand Down

0 comments on commit f63fc6d

Please sign in to comment.