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
ca7eee35
Commit
ca7eee35
authored
Aug 18, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: no ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL events emitted in plain_client_t
Solution: emit events at appropriate places
parent
c66ae465
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
plain_client.cpp
src/plain_client.cpp
+26
-4
plain_client.hpp
src/plain_client.hpp
+5
-5
stream_engine.cpp
src/stream_engine.cpp
+1
-1
No files found.
src/plain_client.cpp
View file @
ca7eee35
...
...
@@ -35,9 +35,11 @@
#include "msg.hpp"
#include "err.hpp"
#include "plain_client.hpp"
#include "session_base.hpp"
zmq
::
plain_client_t
::
plain_client_t
(
const
options_t
&
options_
)
:
mechanism_t
(
options_
),
zmq
::
plain_client_t
::
plain_client_t
(
session_base_t
*
const
session_
,
const
options_t
&
options_
)
:
mechanism_base_t
(
session_
,
options_
),
state
(
sending_hello
)
{
}
...
...
@@ -84,8 +86,9 @@ int zmq::plain_client_t::process_handshake_command (msg_t *msg_)
if
(
data_size
>=
6
&&
!
memcmp
(
cmd_data
,
"
\5
ERROR"
,
6
))
rc
=
process_error
(
cmd_data
,
data_size
);
else
{
// Temporary support for security debugging
puts
(
"PLAIN I: invalid handshake command"
);
// TODO see comment in curve_server_t::process_handshake_command
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED
);
errno
=
EPROTO
;
rc
=
-
1
;
}
...
...
@@ -146,10 +149,15 @@ int zmq::plain_client_t::process_welcome (
LIBZMQ_UNUSED
(
cmd_data
);
if
(
state
!=
waiting_for_welcome
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND
);
errno
=
EPROTO
;
return
-
1
;
}
if
(
data_size
!=
8
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME
);
errno
=
EPROTO
;
return
-
1
;
}
...
...
@@ -168,12 +176,18 @@ int zmq::plain_client_t::process_ready (
const
unsigned
char
*
cmd_data
,
size_t
data_size
)
{
if
(
state
!=
waiting_for_ready
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND
);
errno
=
EPROTO
;
return
-
1
;
}
const
int
rc
=
parse_metadata
(
cmd_data
+
6
,
data_size
-
6
);
if
(
rc
==
0
)
state
=
ready
;
else
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA
);
return
rc
;
}
...
...
@@ -181,15 +195,23 @@ int zmq::plain_client_t::process_error (
const
unsigned
char
*
cmd_data
,
size_t
data_size
)
{
if
(
state
!=
waiting_for_welcome
&&
state
!=
waiting_for_ready
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND
);
errno
=
EPROTO
;
return
-
1
;
}
if
(
data_size
<
7
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR
);
errno
=
EPROTO
;
return
-
1
;
}
const
size_t
error_reason_len
=
static_cast
<
size_t
>
(
cmd_data
[
6
]);
if
(
error_reason_len
>
data_size
-
7
)
{
session
->
get_socket
()
->
event_handshake_failed_protocol
(
session
->
get_endpoint
(),
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR
);
errno
=
EPROTO
;
return
-
1
;
}
...
...
src/plain_client.hpp
View file @
ca7eee35
...
...
@@ -38,11 +38,11 @@ namespace zmq
class
msg_t
;
class
plain_client_t
:
public
mechanism_t
class
plain_client_t
:
public
mechanism_
base_
t
{
public
:
plain_client_t
(
const
options_t
&
options_
);
public
:
plain_client_t
(
session_base_t
*
const
session_
,
const
options_t
&
options_
);
virtual
~
plain_client_t
();
// mechanism implementation
...
...
@@ -50,7 +50,7 @@ namespace zmq
virtual
int
process_handshake_command
(
msg_t
*
msg_
);
virtual
status_t
status
()
const
;
private
:
private
:
enum
state_t
{
sending_hello
,
...
...
src/stream_engine.cpp
View file @
ca7eee35
...
...
@@ -674,7 +674,7 @@ bool zmq::stream_engine_t::handshake ()
plain_server_t
(
session
,
peer_address
,
options
);
else
mechanism
=
new
(
std
::
nothrow
)
plain_client_t
(
options
);
plain_client_t
(
session
,
options
);
alloc_assert
(
mechanism
);
}
#ifdef ZMQ_HAVE_CURVE
...
...
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