Don't accept an unreasonably large window size.

This commit is contained in:
akwizgran
2012-11-27 15:38:55 +00:00
parent 80543984be
commit 7afd2d8f74
2 changed files with 4 additions and 3 deletions

View File

@@ -11,11 +11,11 @@ import java.util.logging.Logger;
class Receiver implements ReadHandler {
static final int MAX_WINDOW_SIZE = 8 * Data.MAX_PAYLOAD_LENGTH;
private static final Logger LOG =
Logger.getLogger(Receiver.class.getName());
private static final int MAX_WINDOW_SIZE = 8 * Data.MAX_PAYLOAD_LENGTH;
private final Sender sender;
private final SortedSet<Data> dataFrames; // Locking: this

View File

@@ -106,7 +106,8 @@ class Sender {
// Update the window
lastWindowUpdateOrProbe = now;
int oldWindowSize = windowSize;
windowSize = a.getWindowSize();
// Don't accept an unreasonably large window size
windowSize = Math.min(a.getWindowSize(), Receiver.MAX_WINDOW_SIZE);
if(LOG.isLoggable(FINE)) LOG.fine("Window at sender " + windowSize);
// If space has become available, notify any waiting writers
if(windowSize > oldWindowSize || foundIndex != -1) notifyAll();