Commit 25934e9c 25934e9ccda6d60b56f77125a6466e5c6b5de305 by Sergey Poznyakoff

Make sure header reads always return the trailing \n, even for empty headers.

* libmailutils/mailbox/header.c (header_read): Always return trailing \n.
1 parent 4c82a261
......@@ -993,6 +993,22 @@ header_read (mu_stream_t is, char *buffer, size_t buflen, size_t *pnread)
status = mu_header_fill (header);
if (status)
return status;
if (header->spool_size == 0)
{
size_t len = 0;
if (hstr->off == 0 && buflen > 0)
{
/* Provide the trailing \n */
*buffer = '\n';
hstr->off++;
len = 1;
}
if (pnread)
*pnread = len;
return 0;
}
if (mu_hdrent_find_stream_pos (header, hstr->off, &ent, &ent_off))
{
......