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 ...@@ -934,8 +934,14 @@ int
934 header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult) 934 header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
935 { 935 {
936 struct _mu_header_stream *hstr = (struct _mu_header_stream *) str; 936 struct _mu_header_stream *hstr = (struct _mu_header_stream *) str;
937 937 size_t size;
938 if (off < 0 || off > hstr->hdr->size) 938 int status;
939
940 status = mu_header_size (hstr->hdr, &size);
941 if (status)
942 return status;
943
944 if (off < 0 || off > size)
939 return ESPIPE; 945 return ESPIPE;
940 hstr->off = off; 946 hstr->off = off;
941 *presult = off; 947 *presult = off;
......
...@@ -240,6 +240,8 @@ _message_stream_readdelim (struct _mu_stream *str, char *buf, size_t bufsize, ...@@ -240,6 +240,8 @@ _message_stream_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
240 if (sp->state == _mss_eof) 240 if (sp->state == _mss_eof)
241 break; 241 break;
242 rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n); 242 rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n);
243 if (rc || n == 0)
244 break;
243 nread += n; 245 nread += n;
244 buf += n; 246 buf += n;
245 bufsize -= n; 247 bufsize -= n;
......