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
f44300cb
Commit
f44300cb
authored
Mar 29, 2017
by
evoskuil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: assert used for ZAP error handling aborts process.
parent
a6d03df3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
55 deletions
+100
-55
curve_server.cpp
src/curve_server.cpp
+26
-14
curve_server.hpp
src/curve_server.hpp
+1
-1
gssapi_server.cpp
src/gssapi_server.cpp
+22
-10
gssapi_server.hpp
src/gssapi_server.hpp
+1
-1
null_mechanism.cpp
src/null_mechanism.cpp
+21
-10
null_mechanism.hpp
src/null_mechanism.hpp
+1
-1
plain_server.cpp
src/plain_server.cpp
+25
-12
plain_server.hpp
src/plain_server.hpp
+2
-2
session_base.cpp
src/session_base.cpp
+1
-4
No files found.
src/curve_server.cpp
View file @
f44300cb
...
...
@@ -310,12 +310,12 @@ int zmq::curve_server_t::process_hello (msg_t *msg_)
sizeof
hello_box
,
hello_nonce
,
cn_client
,
secret_key
);
if
(
rc
!=
0
)
{
// Temporary support for security debugging
puts
(
"CURVE I: cannot open client HELLO -- wrong server key?"
);
errno
=
EPROTO
;
// Temporary support for security debugging
puts
(
"CURVE I: cannot open client HELLO -- wrong server key?"
);
errno
=
EPROTO
;
return
-
1
;
}
state
=
send_welcome
;
return
rc
;
}
...
...
@@ -492,7 +492,9 @@ int zmq::curve_server_t::process_initiate (msg_t *msg_)
// Use ZAP protocol (RFC 27) to authenticate the user.
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
send_zap_request
(
client_key
);
rc
=
send_zap_request
(
client_key
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
if
(
rc
==
0
)
state
=
status_code
==
"200"
...
...
@@ -569,7 +571,7 @@ int zmq::curve_server_t::produce_error (msg_t *msg_) const
return
0
;
}
void
zmq
::
curve_server_t
::
send_zap_request
(
const
uint8_t
*
key
)
int
zmq
::
curve_server_t
::
send_zap_request
(
const
uint8_t
*
key
)
{
int
rc
;
msg_t
msg
;
...
...
@@ -579,7 +581,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
rc
=
msg
.
init_size
(
3
);
...
...
@@ -587,7 +590,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request ID frame
rc
=
msg
.
init_size
(
1
);
...
...
@@ -595,7 +599,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
...
@@ -603,7 +608,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
...
@@ -611,7 +617,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
...
@@ -619,7 +626,8 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
rc
=
msg
.
init_size
(
5
);
...
...
@@ -627,14 +635,18 @@ void zmq::curve_server_t::send_zap_request (const uint8_t *key)
memcpy
(
msg
.
data
(),
"CURVE"
,
5
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Credentials frame
rc
=
msg
.
init_size
(
crypto_box_PUBLICKEYBYTES
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
key
,
crypto_box_PUBLICKEYBYTES
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
int
zmq
::
curve_server_t
::
receive_and_process_zap_reply
()
...
...
src/curve_server.hpp
View file @
f44300cb
...
...
@@ -125,7 +125,7 @@ namespace zmq
int
produce_ready
(
msg_t
*
msg_
);
int
produce_error
(
msg_t
*
msg_
)
const
;
void
send_zap_request
(
const
uint8_t
*
key
);
int
send_zap_request
(
const
uint8_t
*
key
);
int
receive_and_process_zap_reply
();
};
...
...
src/gssapi_server.cpp
View file @
f44300cb
...
...
@@ -123,7 +123,9 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
bool
expecting_zap_reply
=
false
;
int
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
send_zap_request
();
rc
=
send_zap_request
();
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
if
(
rc
!=
0
)
{
if
(
errno
!=
EAGAIN
)
...
...
@@ -147,7 +149,7 @@ int zmq::gssapi_server_t::process_handshake_command (msg_t *msg_)
return
0
;
}
void
zmq
::
gssapi_server_t
::
send_zap_request
()
int
zmq
::
gssapi_server_t
::
send_zap_request
()
{
int
rc
;
msg_t
msg
;
...
...
@@ -157,7 +159,8 @@ void zmq::gssapi_server_t::send_zap_request ()
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
rc
=
msg
.
init_size
(
3
);
...
...
@@ -165,7 +168,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request ID frame
rc
=
msg
.
init_size
(
1
);
...
...
@@ -173,7 +177,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
...
@@ -181,7 +186,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
...
@@ -189,7 +195,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
...
@@ -197,7 +204,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
rc
=
msg
.
init_size
(
6
);
...
...
@@ -205,7 +213,8 @@ void zmq::gssapi_server_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"GSSAPI"
,
6
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Principal frame
gss_buffer_desc
principal
;
...
...
@@ -215,8 +224,11 @@ void zmq::gssapi_server_t::send_zap_request ()
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
principal
.
value
,
principal
.
length
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
gss_release_buffer
(
&
min_stat
,
&
principal
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
int
zmq
::
gssapi_server_t
::
receive_and_process_zap_reply
()
...
...
src/gssapi_server.hpp
View file @
f44300cb
...
...
@@ -85,7 +85,7 @@ namespace zmq
void
accept_context
();
int
produce_next_token
(
msg_t
*
msg_
);
int
process_next_token
(
msg_t
*
msg_
);
void
send_zap_request
();
int
send_zap_request
();
int
receive_and_process_zap_reply
();
};
...
...
src/null_mechanism.cpp
View file @
f44300cb
...
...
@@ -75,9 +75,11 @@ int zmq::null_mechanism_t::next_handshake_command (msg_t *msg_)
errno
=
EAGAIN
;
return
-
1
;
}
send_zap_request
();
int
rc
=
send_zap_request
();
if
(
rc
!=
0
)
return
-
1
;
zap_request_sent
=
true
;
const
int
rc
=
receive_and_process_zap_reply
();
rc
=
receive_and_process_zap_reply
();
if
(
rc
!=
0
)
return
-
1
;
zap_reply_received
=
true
;
...
...
@@ -212,7 +214,7 @@ zmq::mechanism_t::status_t zmq::null_mechanism_t::status () const
return
handshaking
;
}
void
zmq
::
null_mechanism_t
::
send_zap_request
()
int
zmq
::
null_mechanism_t
::
send_zap_request
()
{
int
rc
;
msg_t
msg
;
...
...
@@ -222,7 +224,8 @@ void zmq::null_mechanism_t::send_zap_request ()
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
rc
=
msg
.
init_size
(
3
);
...
...
@@ -230,7 +233,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request id frame
rc
=
msg
.
init_size
(
1
);
...
...
@@ -238,7 +242,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
...
@@ -246,7 +251,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
...
@@ -254,7 +260,8 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
...
@@ -262,14 +269,18 @@ void zmq::null_mechanism_t::send_zap_request ()
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
rc
=
msg
.
init_size
(
4
);
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
"NULL"
,
4
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
int
zmq
::
null_mechanism_t
::
receive_and_process_zap_reply
()
...
...
src/null_mechanism.hpp
View file @
f44300cb
...
...
@@ -75,7 +75,7 @@ namespace zmq
int
process_error_command
(
const
unsigned
char
*
cmd_data
,
size_t
data_size
);
void
send_zap_request
();
int
send_zap_request
();
int
receive_and_process_zap_reply
();
};
...
...
src/plain_server.cpp
View file @
f44300cb
...
...
@@ -191,7 +191,9 @@ int zmq::plain_server_t::process_hello (msg_t *msg_)
// Use ZAP protocol (RFC 27) to authenticate the user.
int
rc
=
session
->
zap_connect
();
if
(
rc
==
0
)
{
send_zap_request
(
username
,
password
);
rc
=
send_zap_request
(
username
,
password
);
if
(
rc
!=
0
)
return
-
1
;
rc
=
receive_and_process_zap_reply
();
if
(
rc
==
0
)
state
=
status_code
==
"200"
...
...
@@ -277,8 +279,8 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
return
0
;
}
void
zmq
::
plain_server_t
::
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
)
int
zmq
::
plain_server_t
::
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
)
{
int
rc
;
msg_t
msg
;
...
...
@@ -288,7 +290,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
errno_assert
(
rc
==
0
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Version frame
rc
=
msg
.
init_size
(
3
);
...
...
@@ -296,7 +299,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"1.0"
,
3
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Request id frame
rc
=
msg
.
init_size
(
1
);
...
...
@@ -304,7 +308,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"1"
,
1
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Domain frame
rc
=
msg
.
init_size
(
options
.
zap_domain
.
length
());
...
...
@@ -312,7 +317,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
options
.
zap_domain
.
c_str
(),
options
.
zap_domain
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Address frame
rc
=
msg
.
init_size
(
peer_address
.
length
());
...
...
@@ -320,7 +326,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
peer_address
.
c_str
(),
peer_address
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Identity frame
rc
=
msg
.
init_size
(
options
.
identity_size
);
...
...
@@ -328,7 +335,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
options
.
identity
,
options
.
identity_size
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Mechanism frame
rc
=
msg
.
init_size
(
5
);
...
...
@@ -336,7 +344,8 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
"PLAIN"
,
5
);
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Username frame
rc
=
msg
.
init_size
(
username
.
length
());
...
...
@@ -344,14 +353,18 @@ void zmq::plain_server_t::send_zap_request (const std::string &username,
memcpy
(
msg
.
data
(),
username
.
c_str
(),
username
.
length
());
msg
.
set_flags
(
msg_t
::
more
);
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
// Password frame
rc
=
msg
.
init_size
(
password
.
length
());
errno_assert
(
rc
==
0
);
memcpy
(
msg
.
data
(),
password
.
c_str
(),
password
.
length
());
rc
=
session
->
write_zap_msg
(
&
msg
);
errno_assert
(
rc
==
0
);
if
(
rc
!=
0
)
return
-
1
;
return
0
;
}
int
zmq
::
plain_server_t
::
receive_and_process_zap_reply
()
...
...
src/plain_server.hpp
View file @
f44300cb
...
...
@@ -83,8 +83,8 @@ namespace zmq
int
process_hello
(
msg_t
*
msg_
);
int
process_initiate
(
msg_t
*
msg_
);
void
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
);
int
send_zap_request
(
const
std
::
string
&
username
,
const
std
::
string
&
password
);
int
receive_and_process_zap_reply
();
};
...
...
src/session_base.cpp
View file @
f44300cb
...
...
@@ -183,14 +183,11 @@ int zmq::session_base_t::read_zap_msg (msg_t *msg_)
int
zmq
::
session_base_t
::
write_zap_msg
(
msg_t
*
msg_
)
{
if
(
zap_pipe
==
NULL
)
{
if
(
zap_pipe
==
NULL
||
!
zap_pipe
->
write
(
msg_
)
)
{
errno
=
ENOTCONN
;
return
-
1
;
}
const
bool
ok
=
zap_pipe
->
write
(
msg_
);
zmq_assert
(
ok
);
if
((
msg_
->
flags
()
&
msg_t
::
more
)
==
0
)
zap_pipe
->
flush
();
...
...
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