mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 631b6c7c826477ebc3b8b59a2a77df8592e0c627
parent f56755cffd420ce44f6fac519bc7b857a5d06410
Author: Christian Neukirchen <chneukirchen@gmail.com>
Date:   Thu,  6 Oct 2016 16:47:13 +0200

slurp: zero-terminate buffer

Diffstat:
slurp.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/slurp.c b/slurp.c @@ -29,7 +29,7 @@ slurp(char *filename, char **bufo, off_t *leno) *leno = 0; return 0; } - *bufo = malloc(st.st_size); + *bufo = malloc(st.st_size + 1); if (!*bufo) { r = ENOMEM; goto out; @@ -48,7 +48,9 @@ slurp(char *filename, char **bufo, off_t *leno) break; nread += n; } while (nread < st.st_size); + *leno = nread; + (*bufo)[st.st_size] = 0; out: close(fd);