X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/8e1fbe44dde847482ecdf54f97d31a5322a2fd92..59d43aadba53b164dc529cfef069c5aeb9a65807:/src/lbxtool.c diff --git a/src/lbxtool.c b/src/lbxtool.c index 767c309..3c4e436 100644 --- a/src/lbxtool.c +++ b/src/lbxtool.c @@ -110,19 +110,19 @@ int extract_file(LBXfile *f, const struct lbx_statbuf *stat) unsigned char buf[1024]; rc = lbx_file_read(f, buf, sizeof buf); - if (rc == 0) { - if (lbx_file_eof(f)) - ret = 0; - break; - } - - if (fwrite(buf, rc, 1, of) != 1) { - tool_err(0, "%s: fwrite", stat->name); - break; + if (rc > 0) { + /* Write out any data we got. */ + if (fwrite(buf, rc, 1, of) != 1) { + tool_err(0, "%s: fwrite", stat->name); + break; + } } + /* Now test for read errors */ if (rc < sizeof buf) { - if (lbx_file_eof(f)) + if (!lbx_file_eof(f)) + tool_err(-1, "error reading archive: %s", lbx_errmsg()); + else ret = 0; break; }