Merge "Fix possible arithmetic overflow when setting a timeout"

This commit is contained in:
Shawn Pearce 2015-12-15 23:16:19 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit 8b749f7de5
1 changed files with 2 additions and 1 deletions

View File

@ -385,7 +385,8 @@ private String readStringLongTimeout() throws IOException {
final int oldTimeout = timeoutIn.getTimeout();
final int sendTime = (int) Math.min(packTransferTime, 28800000L);
try {
timeoutIn.setTimeout(10 * Math.max(sendTime, oldTimeout));
int timeout = 10 * Math.max(sendTime, oldTimeout);
timeoutIn.setTimeout((timeout < 0) ? Integer.MAX_VALUE : timeout);
return pckIn.readString();
} finally {
timeoutIn.setTimeout(oldTimeout);