Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
458ccb36
Commit
458ccb36
authored
Jun 07, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore unknown frame types
Unexpected CONTINUATION frame is handled separately as connection error.
parent
3db8935e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
7 deletions
+100
-7
lib/nghttp2_session.c
lib/nghttp2_session.c
+18
-7
tests/main.c
tests/main.c
+4
-0
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+76
-0
tests/nghttp2_session_test.h
tests/nghttp2_session_test.h
+2
-0
No files found.
lib/nghttp2_session.c
View file @
458ccb36
...
...
@@ -4456,6 +4456,22 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
iframe
->
state
=
NGHTTP2_IB_READ_NBYTE
;
inbound_frame_set_mark
(
iframe
,
8
);
break
;
case
NGHTTP2_CONTINUATION
:
DEBUGF
(
fprintf
(
stderr
,
"recv: unexpected CONTINUATION
\n
"
));
/* Receiving CONTINUATION in this state are subject to
connection error of type PROTOCOL_ERROR */
rv
=
nghttp2_session_terminate_session
(
session
,
NGHTTP2_PROTOCOL_ERROR
);
if
(
nghttp2_is_fatal
(
rv
))
{
return
rv
;
}
busy
=
1
;
iframe
->
state
=
NGHTTP2_IB_IGN_PAYLOAD
;
break
;
case
NGHTTP2_ALTSVC
:
DEBUGF
(
fprintf
(
stderr
,
"recv: ALTSVC
\n
"
));
...
...
@@ -4512,13 +4528,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
default:
DEBUGF
(
fprintf
(
stderr
,
"recv: unknown frame
\n
"
));
/* Receiving unknown frame type and CONTINUATION in this state
are subject to connection error of type PROTOCOL_ERROR */
rv
=
nghttp2_session_terminate_session
(
session
,
NGHTTP2_PROTOCOL_ERROR
);
if
(
nghttp2_is_fatal
(
rv
))
{
return
rv
;
}
/* Silently ignore unknown frame type. */
busy
=
1
;
...
...
@@ -4849,6 +4859,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
switch
(
iframe
->
frame
.
hd
.
type
)
{
case
NGHTTP2_HEADERS
:
case
NGHTTP2_PUSH_PROMISE
:
case
NGHTTP2_CONTINUATION
:
/* Mark inflater bad so that we won't perform further decoding */
session
->
hd_inflater
.
ctx
.
bad
=
1
;
break
;
...
...
tests/main.c
View file @
458ccb36
...
...
@@ -89,6 +89,10 @@ int main(int argc, char* argv[])
test_nghttp2_session_recv_premature_headers
)
||
!
CU_add_test
(
pSuite
,
"session_recv_altsvc"
,
test_nghttp2_session_recv_altsvc
)
||
!
CU_add_test
(
pSuite
,
"session_recv_unknown_frame"
,
test_nghttp2_session_recv_unknown_frame
)
||
!
CU_add_test
(
pSuite
,
"session_recv_unexpected_continuation"
,
test_nghttp2_session_recv_unexpected_continuation
)
||
!
CU_add_test
(
pSuite
,
"session_continue"
,
test_nghttp2_session_continue
)
||
!
CU_add_test
(
pSuite
,
"session_add_frame"
,
test_nghttp2_session_add_frame
)
||
...
...
tests/nghttp2_session_test.c
View file @
458ccb36
...
...
@@ -1146,6 +1146,82 @@ void test_nghttp2_session_recv_altsvc(void)
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_recv_unknown_frame
(
void
)
{
nghttp2_session
*
session
;
nghttp2_session_callbacks
callbacks
;
my_user_data
ud
;
uint8_t
data
[
16384
];
size_t
datalen
;
nghttp2_frame_hd
hd
;
ssize_t
rv
;
hd
.
length
=
16000
;
hd
.
stream_id
=
0
;
hd
.
type
=
99
;
hd
.
flags
=
NGHTTP2_FLAG_NONE
;
nghttp2_frame_pack_frame_hd
(
data
,
&
hd
);
datalen
=
NGHTTP2_FRAME_HDLEN
+
hd
.
length
;
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
on_frame_recv_callback
=
on_frame_recv_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
ud
.
frame_recv_cb_called
=
0
;
/* Unknown frame must be ignored */
rv
=
nghttp2_session_mem_recv
(
session
,
data
,
datalen
);
CU_ASSERT
(
rv
==
(
ssize_t
)
datalen
);
CU_ASSERT
(
0
==
ud
.
frame_recv_cb_called
);
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_recv_unexpected_continuation
(
void
)
{
nghttp2_session
*
session
;
nghttp2_session_callbacks
callbacks
;
my_user_data
ud
;
uint8_t
data
[
16384
];
size_t
datalen
;
nghttp2_frame_hd
hd
;
ssize_t
rv
;
nghttp2_outbound_item
*
item
;
hd
.
length
=
16000
;
hd
.
stream_id
=
1
;
hd
.
type
=
NGHTTP2_CONTINUATION
;
hd
.
flags
=
NGHTTP2_FLAG_END_HEADERS
;
nghttp2_frame_pack_frame_hd
(
data
,
&
hd
);
datalen
=
NGHTTP2_FRAME_HDLEN
+
hd
.
length
;
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
on_frame_recv_callback
=
on_frame_recv_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
open_stream
(
session
,
1
);
ud
.
frame_recv_cb_called
=
0
;
/* unexpected CONTINUATION must be treated as connection error */
rv
=
nghttp2_session_mem_recv
(
session
,
data
,
datalen
);
CU_ASSERT
(
rv
==
(
ssize_t
)
datalen
);
CU_ASSERT
(
0
==
ud
.
frame_recv_cb_called
);
item
=
nghttp2_session_get_next_ob_item
(
session
);
CU_ASSERT
(
NGHTTP2_GOAWAY
==
OB_CTRL_TYPE
(
item
));
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_continue
(
void
)
{
nghttp2_session
*
session
;
...
...
tests/nghttp2_session_test.h
View file @
458ccb36
...
...
@@ -34,6 +34,8 @@ void test_nghttp2_session_recv_continuation(void);
void
test_nghttp2_session_recv_headers_with_priority
(
void
);
void
test_nghttp2_session_recv_premature_headers
(
void
);
void
test_nghttp2_session_recv_altsvc
(
void
);
void
test_nghttp2_session_recv_unknown_frame
(
void
);
void
test_nghttp2_session_recv_unexpected_continuation
(
void
);
void
test_nghttp2_session_continue
(
void
);
void
test_nghttp2_session_add_frame
(
void
);
void
test_nghttp2_session_on_request_headers_received
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment