mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Don't accept an unreasonably large window size.
This commit is contained in:
@@ -11,11 +11,11 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
class Receiver implements ReadHandler {
|
class Receiver implements ReadHandler {
|
||||||
|
|
||||||
|
static final int MAX_WINDOW_SIZE = 8 * Data.MAX_PAYLOAD_LENGTH;
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(Receiver.class.getName());
|
Logger.getLogger(Receiver.class.getName());
|
||||||
|
|
||||||
private static final int MAX_WINDOW_SIZE = 8 * Data.MAX_PAYLOAD_LENGTH;
|
|
||||||
|
|
||||||
private final Sender sender;
|
private final Sender sender;
|
||||||
private final SortedSet<Data> dataFrames; // Locking: this
|
private final SortedSet<Data> dataFrames; // Locking: this
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ class Sender {
|
|||||||
// Update the window
|
// Update the window
|
||||||
lastWindowUpdateOrProbe = now;
|
lastWindowUpdateOrProbe = now;
|
||||||
int oldWindowSize = windowSize;
|
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(LOG.isLoggable(FINE)) LOG.fine("Window at sender " + windowSize);
|
||||||
// If space has become available, notify any waiting writers
|
// If space has become available, notify any waiting writers
|
||||||
if(windowSize > oldWindowSize || foundIndex != -1) notifyAll();
|
if(windowSize > oldWindowSize || foundIndex != -1) notifyAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user