fix slurp(), it needs to read size-1 for the trailing NUL
This commit is contained in:
parent
ebfafc5dac
commit
31509b0d56
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user