Mercurial > hg > orthanc
changeset 4455:a8f554ca5ac6
Explicitly use little-endian to encode uncompressed file size with zlib compression
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 19 Jan 2021 14:31:04 +0100 |
parents | f20a7655fb1c |
children | 3e4f7b7840f0 |
files | NEWS OrthancFramework/Sources/Compression/ZlibCompressor.cpp |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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<uint64_t>(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<uLongf>(uncompressedSize); int error = uncompress (reinterpret_cast<uint8_t*>(&uncompressed[0]),