From fd162fc5d8e4c9cb601bd02f11fb8aa480b6cea4 Mon Sep 17 00:00:00 2001 From: Jan Moringen Date: Sun, 13 Aug 2017 08:54:29 +0200 Subject: [PATCH] Fix inflate_core_bytes(), write_bytes_to_file(), broken by fc685a79 Change sizeof(buf) to ZLIB_BUFFER_SIZE. --- src/runtime/coreparse.c | 2 +- src/runtime/save.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/coreparse.c b/src/runtime/coreparse.c index 8931fe440..0293ccbb9 100644 --- a/src/runtime/coreparse.c +++ b/src/runtime/coreparse.c @@ -237,7 +237,7 @@ void inflate_core_bytes(int fd, os_vm_offset_t offset, stream.next_out = (void*)addr; stream.avail_out = len; do { - ssize_t count = read(fd, buf, sizeof(buf)); + ssize_t count = read(fd, buf, ZLIB_BUFFER_SIZE); if (count < 0) lose("unable to read core file (errno = %i)\n", errno); stream.next_in = buf; diff --git a/src/runtime/save.c b/src/runtime/save.c index 15338f81a..a6d6353d5 100644 --- a/src/runtime/save.c +++ b/src/runtime/save.c @@ -107,12 +107,12 @@ write_bytes_to_file(FILE * file, char *addr, long bytes, int compression) if (ret != Z_OK) lose("deflateInit: %i\n", ret); do { - stream.avail_out = sizeof(buf); + stream.avail_out = ZLIB_BUFFER_SIZE; stream.next_out = buf; ret = deflate(&stream, Z_FINISH); if (ret < 0) lose("zlib deflate error: %i... exiting\n", ret); written = buf; - end = buf+sizeof(buf)-stream.avail_out; + end = buf+ZLIB_BUFFER_SIZE-stream.avail_out; total_written += end - written; while (written < end) { long count = fwrite(written, 1, end-written, file); -- 2.11.4.GIT