diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2011-07-13 19:17:24 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2011-07-13 19:17:24 +0200 |
commit | 2e621680c4efc394df2c66535ded6bd6b5a060b8 (patch) | |
tree | 22ca36d201a24aa169a31fba30f8e45f6a25d61b /src/general.c | |
parent | 7728c35401cf53dc87832c9bb1b0bfe32fa1ed92 (diff) |
slurp(): null-terminate buffer (Thanks mist)
Diffstat (limited to 'src/general.c')
-rw-r--r-- | src/general.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/general.c b/src/general.c index 2ae90f1..bf7afd1 100644 --- a/src/general.c +++ b/src/general.c @@ -19,7 +19,9 @@ bool slurp(const char *filename, char *destination, int size) { if ((fd = open(filename, O_RDONLY)) == -1) return false; - (void)read(fd, destination, size); + int n = read(fd, destination, size); + if (n != -1) + destination[n] = '\0'; (void)close(fd); return true; |