From 55f0a5503e0389263bb69a98932a3e15a3d52093 Mon Sep 17 00:00:00 2001 From: somdoron Date: Mon, 16 May 2016 12:16:12 +0300 Subject: [PATCH] problem: dgram is not enforcing two-part message --- src/dgram.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dgram.cpp b/src/dgram.cpp index 0ae0b289..eecd66cb 100644 --- a/src/dgram.cpp +++ b/src/dgram.cpp @@ -99,7 +99,7 @@ int zmq::dgram_t::xsend (msg_t *msg_) // If this is the first part of the message it's the ID of the // peer to send the message to. - if (!more_out) { + if (!more_out) { if (!(msg_->flags () & msg_t::more)) { errno = EINVAL; return -1; @@ -109,6 +109,13 @@ int zmq::dgram_t::xsend (msg_t *msg_) more_out = true; } else { + + // dgram messages are two part only, reject part if more is set + if (msg_->flags () & msg_t::more) { + errno = EINVAL; + return -1; + } + // This is the last part of the message. more_out = false; } @@ -158,9 +165,6 @@ bool zmq::dgram_t::xhas_in () bool zmq::dgram_t::xhas_out () { - //if (more_out) - // return false; - if (!pipe) return false;