From f3754fb4e4706452c113bd0e4ef0d65a1afe60bc Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Mon, 14 May 2012 23:33:54 +0200 Subject: [PATCH] Fix Windows file read discrepancy. --- src/util/misc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;