slurp(): null-terminate buffer (Thanks mist)

This commit is contained in:
Michael Stapelberg 2011-07-13 19:17:24 +02:00
parent 7728c35401
commit 2e621680c4

View File

@ -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;