summaryrefslogtreecommitdiff
path: root/mailbox
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-06-26 19:36:21 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-06-26 19:36:21 +0000
commit21fb9ca7326589a8ad8d0f2b5247e7a73ad62622 (patch)
tree9df88ae414d92c4809802993e779b19e7c0de936 /mailbox
parent7aa6a66b19e195990360371c7d237a6e4e219d10 (diff)
downloadmailutils-21fb9ca7326589a8ad8d0f2b5247e7a73ad62622.tar.gz
mailutils-21fb9ca7326589a8ad8d0f2b5247e7a73ad62622.tar.bz2
(header_readline): Always nul-terminate the buffer.
Diffstat (limited to 'mailbox')
-rw-r--r--mailbox/header.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mailbox/header.c b/mailbox/header.c
index 0245df1ca..043620689 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -985,7 +985,7 @@ header_readline (mu_stream_t is, char *buffer, size_t buflen,
int status;
size_t strsize;
- if (is == NULL)
+ if (is == NULL || buflen == 0)
return EINVAL;
header = mu_stream_get_owner (is);
@@ -1001,10 +1001,12 @@ header_readline (mu_stream_t is, char *buffer, size_t buflen,
}
strsize = MU_STR_SIZE (ent->nlen, ent->vlen) - ent_off;
+ buflen--; /* Account for the terminating nul */
if (buflen > strsize)
buflen = strsize;
mu_hdrent_fixup (header, ent);
memcpy (buffer, MU_HDRENT_NAME (header, ent) + ent_off, buflen);
+ buffer[buflen] = 0;
mu_hdrent_unroll_fixup (header, ent);
if (pnread)
*pnread = buflen;

Return to:

Send suggestions and report system problems to the System administrator.