mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-29 12:18:04 +01:00
handle decoding malformed messages
Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
This commit is contained in:
committed by
Martin Sustrik
parent
8d6979922e
commit
71bef330fc
@@ -98,9 +98,13 @@ namespace zmq
|
||||
read_pos += size_;
|
||||
to_read -= size_;
|
||||
|
||||
while (!to_read)
|
||||
if (!(static_cast <T*> (this)->*next) ())
|
||||
while (!to_read) {
|
||||
if (!(static_cast <T*> (this)->*next) ()) {
|
||||
if (unlikely (!(static_cast <T*> (this)->next)))
|
||||
return (size_t) -1;
|
||||
return size_;
|
||||
}
|
||||
}
|
||||
return size_;
|
||||
}
|
||||
|
||||
@@ -109,9 +113,13 @@ namespace zmq
|
||||
|
||||
// Try to get more space in the message to fill in.
|
||||
// If none is available, return.
|
||||
while (!to_read)
|
||||
if (!(static_cast <T*> (this)->*next) ())
|
||||
while (!to_read) {
|
||||
if (!(static_cast <T*> (this)->*next) ()) {
|
||||
if (unlikely (!(static_cast <T*> (this)->next)))
|
||||
return (size_t) -1;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no more data in the buffer, return.
|
||||
if (pos == size_)
|
||||
@@ -142,6 +150,13 @@ namespace zmq
|
||||
next = next_;
|
||||
}
|
||||
|
||||
// This function should be called from the derived class to
|
||||
// abort decoder state machine.
|
||||
inline void decoding_error ()
|
||||
{
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
unsigned char *read_pos;
|
||||
|
||||
Reference in New Issue
Block a user