Added checks on the validity of the streamId.

This commit is contained in:
Simone Bordet 2014-06-16 10:38:01 +02:00
parent 7613385578
commit 907d303774
5 changed files with 25 additions and 0 deletions

View File

@ -62,6 +62,11 @@ public class DataBodyParser extends BodyParser
{ {
case PREPARE: case PREPARE:
{ {
// SPEC: wrong streamId is treated as connection error.
if (getStreamId() == 0)
{
return notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR, "invalid_data_frame");
}
length = getBodyLength(); length = getBodyLength();
if (isPaddingHigh()) if (isPaddingHigh())
{ {

View File

@ -73,6 +73,11 @@ public class HeadersBodyParser extends BodyParser
{ {
case PREPARE: case PREPARE:
{ {
// SPEC: wrong streamId is treated as connection error.
if (getStreamId() == 0)
{
return notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR, "invalid_headers_frame");
}
length = getBodyLength(); length = getBodyLength();
if (isPaddingHigh()) if (isPaddingHigh())
{ {

View File

@ -51,6 +51,11 @@ public class PriorityBodyParser extends BodyParser
{ {
case PREPARE: case PREPARE:
{ {
// SPEC: wrong streamId is treated as connection error.
if (getStreamId() == 0)
{
return notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR, "invalid_priority_frame");
}
int length = getBodyLength(); int length = getBodyLength();
if (length != 5) if (length != 5)
{ {

View File

@ -49,6 +49,11 @@ public class ResetBodyParser extends BodyParser
{ {
case PREPARE: case PREPARE:
{ {
// SPEC: wrong streamId is treated as connection error.
if (getStreamId() == 0)
{
return notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR, "invalid_rst_stream_frame");
}
int length = getBodyLength(); int length = getBodyLength();
if (length != 4) if (length != 4)
{ {

View File

@ -64,6 +64,11 @@ public class SettingsBodyParser extends BodyParser
{ {
case PREPARE: case PREPARE:
{ {
// SPEC: wrong streamId is treated as connection error.
if (getStreamId() != 0)
{
return notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR, "invalid_settings_frame");
}
length = getBodyLength(); length = getBodyLength();
settings = new HashMap<>(); settings = new HashMap<>();
state = State.SETTING_ID; state = State.SETTING_ID;