Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
6b6a5227
Unverified
Commit
6b6a5227
authored
Jul 10, 2023
by
Dominik Charousset
Committed by
GitHub
Jul 10, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1476
Fix bug when the first frame is invalid
parents
9498fc8a
c89a1d1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
libcaf_net/src/net/web_socket/framing.cpp
libcaf_net/src/net/web_socket/framing.cpp
+8
-7
libcaf_net/test/net/web_socket/framing.cpp
libcaf_net/test/net/web_socket/framing.cpp
+13
-1
No files found.
libcaf_net/src/net/web_socket/framing.cpp
View file @
6b6a5227
...
...
@@ -85,6 +85,14 @@ ptrdiff_t framing::consume(byte_span buffer, byte_span) {
}
return
handle
(
hdr
.
opcode
,
payload
,
frame_size
);
}
if
(
opcode_
==
nil_code
&&
hdr
.
opcode
==
detail
::
rfc6455
::
continuation_frame
)
{
CAF_LOG_DEBUG
(
"received WebSocket continuation "
"frame without prior opcode"
);
abort_and_shutdown
(
sec
::
protocol_error
,
"received WebSocket continuation "
"frame without prior opcode"
);
return
-
1
;
}
if
(
hdr
.
fin
)
{
if
(
opcode_
==
nil_code
)
{
// Call upper layer.
...
...
@@ -106,13 +114,6 @@ ptrdiff_t framing::consume(byte_span buffer, byte_span) {
// The first frame must not be a continuation frame. Any frame that is not
// the first frame must be a continuation frame.
if
(
opcode_
==
nil_code
)
{
if
(
hdr
.
opcode
==
detail
::
rfc6455
::
continuation_frame
)
{
CAF_LOG_DEBUG
(
"received WebSocket continuation "
"frame without prior opcode"
);
abort_and_shutdown
(
sec
::
protocol_error
,
"received WebSocket continuation "
"frame without prior opcode"
);
return
-
1
;
}
opcode_
=
hdr
.
opcode
;
}
else
if
(
hdr
.
opcode
!=
detail
::
rfc6455
::
continuation_frame
)
{
CAF_LOG_DEBUG
(
"expected a continuation frame"
);
...
...
libcaf_net/test/net/web_socket/framing.cpp
View file @
6b6a5227
...
...
@@ -449,7 +449,19 @@ SCENARIO("apps reject frames whose payload exceeds maximum allowed size") {
SCENARIO
(
"the application shuts down on invalid frame fragments"
)
{
GIVEN
(
"a client that sends invalid fragmented frames"
)
{
WHEN
(
"the first fragment is a continuation frame"
)
{
WHEN
(
"the first fragment is a continuation frame with FIN flag"
)
{
reset
();
byte_buffer
input
;
const
auto
data
=
make_test_data
(
10
);
detail
::
rfc6455
::
assemble_frame
(
detail
::
rfc6455
::
continuation_frame
,
0x0
,
data
,
input
);
transport
->
push
(
input
);
THEN
(
"the app closes the connection with a protocol error"
)
{
CHECK_EQ
(
transport
->
handle_input
(),
0
);
CHECK_EQ
(
app
->
abort_reason
,
sec
::
protocol_error
);
}
}
WHEN
(
"the first fragment is a continuation frame without FIN flag"
)
{
reset
();
byte_buffer
input
;
const
auto
data
=
make_test_data
(
10
);
...
...
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