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
cc9f5516
Commit
cc9f5516
authored
Mar 01, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix heap-buffer-overflow
parent
26e77f1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
libcaf_net/caf/net/stream_transport.hpp
libcaf_net/caf/net/stream_transport.hpp
+16
-6
No files found.
libcaf_net/caf/net/stream_transport.hpp
View file @
cc9f5516
...
...
@@ -395,16 +395,25 @@ public:
"consumed < 0"
));
return
read_result
::
stop
;
}
// Shift unconsumed bytes to the beginning of the buffer.
if
(
consumed
<
offset_
)
if
(
consumed
==
0
)
{
delta_offset_
=
offset_
;
}
else
if
(
consumed
>
0
&&
consumed
<
offset_
)
{
// Shift unconsumed bytes to the beginning of the buffer.
std
::
copy
(
read_buf_
.
begin
()
+
consumed
,
read_buf_
.
begin
()
+
offset_
,
read_buf_
.
begin
());
offset_
-=
consumed
;
delta_offset_
=
offset_
;
offset_
-=
consumed
;
delta_offset_
=
offset_
;
}
else
if
(
consumed
==
offset_
)
{
offset_
=
0
;
delta_offset_
=
0
;
}
// Stop if the application asked for it.
if
(
max_read_size_
==
0
)
return
read_result
::
stop
;
if
(
internal_buffer_size
>
0
&&
offset_
<
max_read_size_
)
{
if
(
internal_buffer_size
>
0
&&
max_read_size_
>
offset_
)
{
// Make sure our buffer has sufficient space.
if
(
read_buf_
.
size
()
<
max_read_size_
)
read_buf_
.
resize
(
max_read_size_
);
// Fetch already buffered data to 'refill' the buffer as we go.
auto
n
=
std
::
min
(
internal_buffer_size
,
max_read_size_
-
static_cast
<
size_t
>
(
offset_
));
...
...
@@ -415,7 +424,8 @@ public:
"policy error: reading buffered data "
"may not result in an error"
));
offset_
+=
rd
;
internal_buffer_size
=
policy_
.
buffered
();
internal_buffer_size
-=
rd
;
CAF_ASSERT
(
internal_buffer_size
==
policy_
.
buffered
());
}
}
while
(
internal_buffer_size
>
0
);
}
...
...
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