diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-06-26 19:36:21 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-06-26 19:36:21 +0000 |
commit | 21fb9ca7326589a8ad8d0f2b5247e7a73ad62622 (patch) | |
tree | 9df88ae414d92c4809802993e779b19e7c0de936 /mailbox | |
parent | 7aa6a66b19e195990360371c7d237a6e4e219d10 (diff) | |
download | mailutils-21fb9ca7326589a8ad8d0f2b5247e7a73ad62622.tar.gz mailutils-21fb9ca7326589a8ad8d0f2b5247e7a73ad62622.tar.bz2 |
(header_readline): Always nul-terminate the buffer.
Diffstat (limited to 'mailbox')
-rw-r--r-- | mailbox/header.c | 4 |
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; |