diff options
| author | Michael Stapelberg | 2013-11-09 14:12:22 +0100 | 
|---|---|---|
| committer | Michael Stapelberg | 2013-11-09 14:37:04 +0100 | 
| commit | 31509b0d5654baf2e2c3438cae90c30e3dd00c17 (patch) | |
| tree | ccdaca3df930a872837d6a2a92f49299a5f41cce /src | |
| parent | print_cpu_temperature: fix memory leak (Thanks kuba) (diff) | |
fix slurp(), it needs to read size-1 for the trailing NUL
Diffstat (limited to 'src')
| -rw-r--r-- | src/general.c | 3 | 
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); | 
