From 41b6631f684558afc95f8b4288f6736cd71a758b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 26 Mar 2010 03:04:54 +0100 Subject: [PATCH] Bugfix: null-terminate buffer --- src/cfgparse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cfgparse.y b/src/cfgparse.y index e2b03412..2774f05c 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -70,7 +70,7 @@ void parse_file(const char *f) { if (fstat(fd, &stbuf) == -1) die("Could not fstat file: %s\n", strerror(errno)); - buf = smalloc(stbuf.st_size * sizeof(char)); + buf = scalloc((stbuf.st_size + 1) * sizeof(char)); while (read_bytes < stbuf.st_size) { if ((ret = read(fd, buf + read_bytes, (stbuf.st_size - read_bytes))) < 0) die("Could not read(): %s\n", strerror(errno));