diff --git a/src/util/misc.c b/src/util/misc.c index 592c8b7..e3a809a 100644 --- a/src/util/misc.c +++ b/src/util/misc.c @@ -244,7 +244,7 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler) return -2; } - ret = read(fd, buf, MAX_RECV_BUF); + ret = read(fd, buf, MAX_RECV_BUF-1); close(fd); if (ret < 0) @@ -258,6 +258,8 @@ int file_read_lines(const char* file, void* data, file_line_handler_t handler) return 0; } + buf[ret] = 0; + /* Parse configuration */ split_data.handler = handler; split_data.data = data;