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
661bccb5
Commit
661bccb5
authored
Nov 07, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1250 from c-rack/master
No error-checking of setsockopt ZMQ_CURVE_* z85 keys. Solves #1094.
parents
6d9f97ad
e00ea532
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
24 deletions
+45
-24
options.cpp
src/options.cpp
+29
-23
test_security_curve.cpp
tests/test_security_curve.cpp
+16
-1
No files found.
src/options.cpp
View file @
661bccb5
...
...
@@ -376,19 +376,21 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
else
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
+
1
)
{
zmq_z85_decode
(
curve_public_key
,
(
char
*
)
optval_
);
mechanism
=
ZMQ_CURVE
;
return
0
;
if
(
zmq_z85_decode
(
curve_public_key
,
(
char
*
)
optval_
))
{
mechanism
=
ZMQ_CURVE
;
return
0
;
}
}
else
// Deprecated, not symmetrical with zmq_getsockopt
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
)
{
char
z85_key
[
4
1
];
char
z85_key
[
CURVE_KEYSIZE_Z85
+
1
];
memcpy
(
z85_key
,
(
char
*
)
optval_
,
CURVE_KEYSIZE_Z85
);
z85_key
[
CURVE_KEYSIZE_Z85
]
=
0
;
zmq_z85_decode
(
curve_public_key
,
z85_key
);
mechanism
=
ZMQ_CURVE
;
return
0
;
if
(
zmq_z85_decode
(
curve_public_key
,
z85_key
))
{
mechanism
=
ZMQ_CURVE
;
return
0
;
}
}
break
;
...
...
@@ -400,19 +402,21 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
else
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
+
1
)
{
zmq_z85_decode
(
curve_secret_key
,
(
char
*
)
optval_
);
mechanism
=
ZMQ_CURVE
;
return
0
;
if
(
zmq_z85_decode
(
curve_secret_key
,
(
char
*
)
optval_
))
{
mechanism
=
ZMQ_CURVE
;
return
0
;
}
}
else
// Deprecated, not symmetrical with zmq_getsockopt
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
)
{
char
z85_key
[
4
1
];
char
z85_key
[
CURVE_KEYSIZE_Z85
+
1
];
memcpy
(
z85_key
,
(
char
*
)
optval_
,
CURVE_KEYSIZE_Z85
);
z85_key
[
CURVE_KEYSIZE_Z85
]
=
0
;
zmq_z85_decode
(
curve_secret_key
,
z85_key
);
mechanism
=
ZMQ_CURVE
;
return
0
;
if
(
zmq_z85_decode
(
curve_secret_key
,
z85_key
))
{
mechanism
=
ZMQ_CURVE
;
return
0
;
}
}
break
;
...
...
@@ -425,21 +429,23 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
else
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
+
1
)
{
zmq_z85_decode
(
curve_server_key
,
(
char
*
)
optval_
);
mechanism
=
ZMQ_CURVE
;
as_server
=
0
;
return
0
;
if
(
zmq_z85_decode
(
curve_server_key
,
(
char
*
)
optval_
))
{
mechanism
=
ZMQ_CURVE
;
as_server
=
0
;
return
0
;
}
}
else
// Deprecated, not symmetrical with zmq_getsockopt
if
(
optvallen_
==
CURVE_KEYSIZE_Z85
)
{
char
z85_key
[
4
1
];
char
z85_key
[
CURVE_KEYSIZE_Z85
+
1
];
memcpy
(
z85_key
,
(
char
*
)
optval_
,
CURVE_KEYSIZE_Z85
);
z85_key
[
CURVE_KEYSIZE_Z85
]
=
0
;
zmq_z85_decode
(
curve_server_key
,
z85_key
);
mechanism
=
ZMQ_CURVE
;
as_server
=
0
;
return
0
;
if
(
zmq_z85_decode
(
curve_server_key
,
z85_key
))
{
mechanism
=
ZMQ_CURVE
;
as_server
=
0
;
return
0
;
}
}
break
;
# endif
...
...
tests/test_security_curve.cpp
View file @
661bccb5
...
...
@@ -217,7 +217,22 @@ int main (void)
assert
(
rc
==
0
);
expect_bounce_fail
(
server
,
client
);
close_zero_linger
(
client
);
// Check return codes for invalid buffer sizes
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
client
);
errno
=
0
;
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_SERVERKEY
,
server_public
,
123
);
assert
(
rc
==
-
1
&&
errno
==
EINVAL
);
errno
=
0
;
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_PUBLICKEY
,
client_public
,
123
);
assert
(
rc
==
-
1
&&
errno
==
EINVAL
);
errno
=
0
;
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_SECRETKEY
,
client_secret
,
123
);
assert
(
rc
==
-
1
&&
errno
==
EINVAL
);
rc
=
zmq_close
(
client
);
assert
(
rc
==
0
);
// Shutdown
rc
=
zmq_close
(
server
);
assert
(
rc
==
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