summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-04-19 08:08:15 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-04-19 08:08:15 +0200
commit581697695aac72894f2d3fefac904b9d50b3ba67 (patch)
tree1cb79d95271bb924f039ad915347020ff94269dc /src/socket_base.cpp
parent20e0b7cdcb6e8095fbadb80765e9371803184060 (diff)
Message validity is checked in the runtime
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index c9b5c31..9f3b1f6 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -466,11 +466,18 @@ int zmq::socket_base_t::connect (const char *addr_)
int zmq::socket_base_t::send (::zmq_msg_t *msg_, int flags_)
{
+ // Check whether the library haven't been shut down yet.
if (unlikely (ctx_terminated)) {
errno = ETERM;
return -1;
}
+ // Check whether message passed to the function is valid.
+ if (unlikely ((msg_->flags | ZMQ_MSG_MASK) != 0xff)) {
+ errno = EFAULT;
+ return -1;
+ }
+
// Process pending commands, if any.
int rc = process_commands (false, true);
if (unlikely (rc != 0))
@@ -504,11 +511,18 @@ int zmq::socket_base_t::send (::zmq_msg_t *msg_, int flags_)
int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
{
+ // Check whether the library haven't been shut down yet.
if (unlikely (ctx_terminated)) {
errno = ETERM;
return -1;
}
+ // Check whether message passed to the function is valid.
+ if (unlikely ((msg_->flags | ZMQ_MSG_MASK) != 0xff)) {
+ errno = EFAULT;
+ return -1;
+ }
+
// Get the message.
int rc = xrecv (msg_, flags_);
int err = errno;