diff --git a/src/native/corehost/bundle/extractor.cpp b/src/native/corehost/bundle/extractor.cpp index ab2c53295055b9..a1e085ab507d3f 100644 --- a/src/native/corehost/bundle/extractor.cpp +++ b/src/native/corehost/bundle/extractor.cpp @@ -7,6 +7,7 @@ #include "pal.h" #include "utils.h" #include +#include #ifdef __sun #include @@ -156,10 +157,13 @@ void extractor_t::extract(const file_entry_t &entry, reader_t &reader) } int produced = bufSize - zStream.availOut; - if (fwrite(buf, 1, produced, file) != (size_t)produced) + size_t written = fwrite(buf, 1, produced, file); + if (written != (size_t)produced) { CompressionNative_InflateEnd(&zStream); + int err = errno; trace::error(_X("I/O failure when writing decompressed file.")); + trace::error(_X("Expected: %d bytes, Written: %zu bytes, errno: %d, %s"), produced, written, err, pal::strerror(err).c_str()); throw StatusCode::BundleExtractionIOError; } @@ -179,8 +183,10 @@ void extractor_t::extract(const file_entry_t &entry, reader_t &reader) if (extracted_size != cast_size) { + int err = errno; trace::error(_X("Failure extracting contents of the application bundle. Expected size:%" PRId64 " Actual size:%zu"), size, extracted_size); - trace::error(_X("I/O failure when writing extracted files.")); + trace::error(_X("I/O failure when writing extracted files. errno: %d, %s"), err, pal::strerror(err).c_str()); + fclose(file); throw StatusCode::BundleExtractionIOError; }