Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
e17232f7
Commit
e17232f7
authored
Mar 22, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: possible use-after-free
Solution: check for failure and do not access any members afterwards
parent
f083e60d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
stream_engine.cpp
src/stream_engine.cpp
+18
-7
stream_engine.hpp
src/stream_engine.hpp
+2
-0
No files found.
src/stream_engine.cpp
View file @
e17232f7
...
...
@@ -297,13 +297,20 @@ void zmq::stream_engine_t::terminate ()
}
void
zmq
::
stream_engine_t
::
in_event
()
{
// ignore errors
const
bool
res
=
in_event_internal
();
LIBZMQ_UNUSED
(
res
);
}
bool
zmq
::
stream_engine_t
::
in_event_internal
()
{
zmq_assert
(
!
_io_error
);
// If still handshaking, receive and process the greeting message.
if
(
unlikely
(
_handshaking
))
if
(
!
handshake
())
return
;
return
false
;
zmq_assert
(
_decoder
);
...
...
@@ -311,7 +318,7 @@ void zmq::stream_engine_t::in_event ()
if
(
_input_stopped
)
{
rm_fd
(
_handle
);
_io_error
=
true
;
return
;
return
true
;
// TODO or return false in this case too?
}
// If there's no data to process in the buffer...
...
...
@@ -329,12 +336,14 @@ void zmq::stream_engine_t::in_event ()
// connection closed by peer
errno
=
EPIPE
;
error
(
connection_error
);
return
;
return
false
;
}
if
(
rc
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
if
(
errno
!=
EAGAIN
)
{
error
(
connection_error
);
return
;
return
false
;
}
return
true
;
}
// Adjust input size
...
...
@@ -363,13 +372,14 @@ void zmq::stream_engine_t::in_event ()
if
(
rc
==
-
1
)
{
if
(
errno
!=
EAGAIN
)
{
error
(
protocol_error
);
return
;
return
false
;
}
_input_stopped
=
true
;
reset_pollin
(
_handle
);
}
_session
->
flush
();
return
true
;
}
void
zmq
::
stream_engine_t
::
out_event
()
...
...
@@ -497,7 +507,8 @@ bool zmq::stream_engine_t::restart_input ()
_session
->
flush
();
// Speculative read.
in_event
();
if
(
!
in_event_internal
())
return
false
;
}
return
true
;
...
...
src/stream_engine.hpp
View file @
e17232f7
...
...
@@ -87,6 +87,8 @@ class stream_engine_t : public io_object_t, public i_engine
void
timer_event
(
int
id_
);
private
:
bool
in_event_internal
();
// Unplug the engine from the session.
void
unplug
();
...
...
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