Commit 11c14a01 11c14a014892507f7fa1dca4610840a4e4668d43 by Sergey Poznyakoff

Bugfixes

* mailbox/header.c (header_seek): Do not dereference
hstr->hdr->size directly, because it may not be initialized yet.
Use mu_header_size instead.
* mailbox/message.c (_message_stream_readdelim): Break the loop
if mu_stream_readdelim returned error or EOF.
1 parent 1270a9f6
......@@ -934,8 +934,14 @@ int
header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
{
struct _mu_header_stream *hstr = (struct _mu_header_stream *) str;
if (off < 0 || off > hstr->hdr->size)
size_t size;
int status;
status = mu_header_size (hstr->hdr, &size);
if (status)
return status;
if (off < 0 || off > size)
return ESPIPE;
hstr->off = off;
*presult = off;
......
......@@ -240,6 +240,8 @@ _message_stream_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
if (sp->state == _mss_eof)
break;
rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n);
if (rc || n == 0)
break;
nread += n;
buf += n;
bufsize -= n;
......