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) ...@@ -993,6 +993,22 @@ header_read (mu_stream_t is, char *buffer, size_t buflen, size_t *pnread)
993 status = mu_header_fill (header); 993 status = mu_header_fill (header);
994 if (status) 994 if (status)
995 return status; 995 return status;
996
997 if (header->spool_size == 0)
998 {
999 size_t len = 0;
1000
1001 if (hstr->off == 0 && buflen > 0)
1002 {
1003 /* Provide the trailing \n */
1004 *buffer = '\n';
1005 hstr->off++;
1006 len = 1;
1007 }
1008 if (pnread)
1009 *pnread = len;
1010 return 0;
1011 }
996 1012
997 if (mu_hdrent_find_stream_pos (header, hstr->off, &ent, &ent_off)) 1013 if (mu_hdrent_find_stream_pos (header, hstr->off, &ent, &ent_off))
998 { 1014 {
......