Make sure header reads always return the trailing \n, even for empty headers.
* libmailutils/mailbox/header.c (header_read): Always return trailing \n.
Showing
1 changed file
with
16 additions
and
0 deletions
... | @@ -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 | { | ... | ... |
-
Please register or sign in to post a comment