Handle error code in trees_ostream_send_header()

Properly handle the returned value of o_stream_send() so we make sure
the entire header was sent else error on that.

Reported-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
Signed-off-by: David Goulet <dgoulet@riseup.net>
This commit is contained in:
David Goulet 2017-02-17 14:19:34 -05:00
parent 6838535f3a
commit 5a81de94f2

View File

@ -66,10 +66,17 @@ trees_ostream_send_header(struct trees_ostream *sstream)
/* The header here consists of a magic number. */
ssize_t ret = o_stream_send(sstream->ostream.parent, header,
sizeof(header));
if (ret != sizeof(header)) {
o_stream_copy_error_from_parent(&sstream->ostream);
goto err;
}
#ifdef DEBUG_STREAMS
sstream->out_byte_count += sizeof(header);
sstream->out_byte_count += ret;
#endif
return ret;
err:
return -1;
}
static ssize_t