summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDhammika Pathirana <dhammika@gmail.com>2010-08-27 18:06:37 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-09-04 16:59:25 +0200
commit10227899b1ccdaecf709fbfc7b765e147baf3080 (patch)
tree39757f9dd5599e9dee0d3ca0147c82bd2b8b8073
parentc2f3b3b4458187085e148850068f9719c2567614 (diff)
assert on malformed messages
-rw-r--r--src/zmq_decoder.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/zmq_decoder.cpp b/src/zmq_decoder.cpp
index 8e335c9..dcf8e76 100644
--- a/src/zmq_decoder.cpp
+++ b/src/zmq_decoder.cpp
@@ -56,6 +56,9 @@ bool zmq::zmq_decoder_t::one_byte_size_ready ()
// TODO: Handle over-sized message decently.
+ // There has to be at least one byte (the flags) in the message).
+ zmq_assert (*tmpbuf > 0);
+
// in_progress is initialised at this point so in theory we should
// close it before calling zmq_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...
@@ -74,6 +77,10 @@ bool zmq::zmq_decoder_t::eight_byte_size_ready ()
// TODO: Handle over-sized message decently.
+ // There has to be at least one byte (the flags) in the message).
+ zmq_assert (size > 0);
+
+
// in_progress is initialised at this point so in theory we should
// close it before calling zmq_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...