summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2013-11-09 14:12:22 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-11-09 14:37:04 +0100
commit31509b0d5654baf2e2c3438cae90c30e3dd00c17 (patch)
treeccdaca3df930a872837d6a2a92f49299a5f41cce /src
parentebfafc5dac9cb15ec4ec9b13e9b933c9c2c5d5c9 (diff)
fix slurp(), it needs to read size-1 for the trailing NUL
Diffstat (limited to 'src')
-rw-r--r--src/general.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/general.c b/src/general.c
index bf7afd1..7ec80a8 100644
--- a/src/general.c
+++ b/src/general.c
@@ -19,7 +19,8 @@ bool slurp(const char *filename, char *destination, int size) {
if ((fd = open(filename, O_RDONLY)) == -1)
return false;
- int n = read(fd, destination, size);
+ /* We need one byte for the trailing 0 byte */
+ int n = read(fd, destination, size-1);
if (n != -1)
destination[n] = '\0';
(void)close(fd);