diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-18 01:48:58 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-18 01:48:58 +0200 |
commit | fa1336a1c115e2b68cabf169cd4b441972a074ae (patch) | |
tree | 5f8bbd316f46b7e956437c6a786e47759efe666d /src/libmdsserver | |
parent | use memchr rather than strchrnul, the payload is not NUL-terminated (diff) | |
download | mds-fa1336a1c115e2b68cabf169cd4b441972a074ae.tar.gz mds-fa1336a1c115e2b68cabf169cd4b441972a074ae.tar.bz2 mds-fa1336a1c115e2b68cabf169cd4b441972a074ae.tar.xz |
Fix reading of payload
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/mds-message.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c index dccd7d8..62f0967 100644 --- a/src/libmdsserver/mds-message.c +++ b/src/libmdsserver/mds-message.c @@ -99,6 +99,7 @@ int mds_message_read(mds_message_t* restrict this, int fd) this->header_count = 0; free(this->payload); + this->payload = NULL; this->payload_size = 0; this->payload_ptr = 0; @@ -212,12 +213,12 @@ int mds_message_read(mds_message_t* restrict this, int fd) } /* Stage 1: payload. */ - if ((this->stage == 1) && (this->payload_ptr == 0)) + if ((this->stage == 1) && (this->payload_size == 0)) { this->stage = 2; return 0; } - if ((this->stage == 1) && (this->payload_ptr > 0)) + if ((this->stage == 1) && (this->payload_size > 0)) { /* How much of the payload that has not yet been filled. */ size_t need = this->payload_size - this->payload_ptr; |