# HG changeset patch # User Sebastien Jodogne # Date 1611063064 -3600 # Node ID a8f554ca5ac614753682499827285ea166da3326 # Parent f20a7655fb1c49032eb5442ac97a472de0617d8b Explicitly use little-endian to encode uncompressed file size with zlib compression diff -r f20a7655fb1c -r a8f554ca5ac6 NEWS --- a/NEWS Tue Jan 19 12:03:49 2021 +0100 +++ b/NEWS Tue Jan 19 14:31:04 2021 +0100 @@ -27,6 +27,7 @@ * Fix upload of multiple DICOM files using one single POST call to "multipart/form-data" Could be the final resolution of issue #21 (DICOM files missing after uploading with Firefox) * Partial fix of issue #48 (Windows service not stopped properly), cf. comments 4 and 5 +* Explicitly use little-endian to encode uncompressed file size with zlib compression * Upgraded dependencies for static builds (notably on Windows): - jsoncpp 1.9.4 diff -r f20a7655fb1c -r a8f554ca5ac6 OrthancFramework/Sources/Compression/ZlibCompressor.cpp --- a/OrthancFramework/Sources/Compression/ZlibCompressor.cpp Tue Jan 19 12:03:49 2021 +0100 +++ b/OrthancFramework/Sources/Compression/ZlibCompressor.cpp Tue Jan 19 14:31:04 2021 +0100 @@ -23,6 +23,7 @@ #include "../PrecompiledHeaders.h" #include "ZlibCompressor.h" +#include "../Endianness.h" #include "../OrthancException.h" #include "../Logging.h" @@ -90,6 +91,10 @@ if (HasPrefixWithUncompressedSize()) { uint64_t s = static_cast(uncompressedSize); + + // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix + s = htole64(s); + memcpy(&compressed[0], &s, sizeof(uint64_t)); compressed.resize(compressedSize + sizeof(uint64_t)); } @@ -127,6 +132,9 @@ throw OrthancException(ErrorCode_NotEnoughMemory); } + // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix + uncompressedSize = le64toh(uncompressedSize); + uLongf tmp = static_cast(uncompressedSize); int error = uncompress (reinterpret_cast(&uncompressed[0]),