mirror of
https://github.com/square/okhttp.git
synced 2026-01-25 16:01:38 +03:00
Guard against invalid name value block headers.
If a badly behaved server sends us a negative number of name value blocks, we should throw an IOException and not a RTE (which will be thrown when we try to construct an ArrayList with a negative size).
This commit is contained in:
@@ -232,6 +232,10 @@ final class SpdyReader implements Closeable {
|
||||
this.compressedLimit += length;
|
||||
try {
|
||||
int numberOfPairs = nameValueBlockIn.readInt();
|
||||
if (numberOfPairs < 0) {
|
||||
Logger.getLogger(getClass().getName()).warning("numberOfPairs < 0: " + numberOfPairs);
|
||||
throw ioException("numberOfPairs < 0");
|
||||
}
|
||||
List<String> entries = new ArrayList<String>(numberOfPairs * 2);
|
||||
for (int i = 0; i < numberOfPairs; i++) {
|
||||
String name = readString();
|
||||
|
||||
Reference in New Issue
Block a user