mirror of
https://0xacab.org/liberate/trees.git
synced 2024-11-25 11:40:40 +01:00
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:
parent
6838535f3a
commit
5a81de94f2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user