Mercurial > hg > orthanc
changeset 6138:66609557a7ee
cppcheck and safeguard for 32bit architectures
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 May 2025 10:30:04 +0200 |
parents | 9d94f6744753 |
children | d6c777a2511f d6f986202236 |
files | OrthancFramework/Sources/DicomFormat/DicomImageInformation.cpp OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp OrthancFramework/Sources/HttpServer/HttpContentNegociation.h OrthancFramework/Sources/MallocMemoryBuffer.cpp OrthancFramework/Sources/SerializationToolbox.cpp |
diffstat | 7 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomFormat/DicomImageInformation.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomImageInformation.cpp Fri May 30 10:30:04 2025 +0200 @@ -566,7 +566,7 @@ { // Check out "../../../OrthancServer/Resources/ImplementationNotes/windowing.py" - float windowWidth = std::abs(window.GetWidth()); + double windowWidth = std::abs(window.GetWidth()); // Avoid divisions by zero static const double MIN = 0.0001;
--- a/OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp Fri May 30 10:30:04 2025 +0200 @@ -672,7 +672,7 @@ reader.Consume(visitor); isLittleEndian = reader.IsLittleEndian(); } - catch (OrthancException& e) + catch (OrthancException&) { // Invalid DICOM file return false;
--- a/OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp Fri May 30 10:30:04 2025 +0200 @@ -176,7 +176,7 @@ LOG(INFO) << "Created attachment \"" << uuid << "\" (" << timer.GetHumanTransferSpeed(true, size) << ")"; return; } - catch (OrthancException& e) + catch (OrthancException&) { if (retryCount >= maxRetryCount) {
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp Fri May 30 10:30:04 2025 +0200 @@ -113,6 +113,12 @@ } else { + const uint64_t size = end - start; + if (static_cast<uint64_t>(static_cast<size_t>(size)) != size) + { + throw OrthancException(ErrorCode_InternalError, "Buffer larger than 4GB, which is too large for Orthanc running in 32bits"); + } + Mutex::ScopedLock lock(mutex_); Content::const_iterator found = content_.find(uuid); @@ -132,7 +138,7 @@ else { std::string range; - range.resize(end - start); + range.resize(static_cast<size_t>(size)); assert(!range.empty()); memcpy(&range[0], &found->second[start], range.size());
--- a/OrthancFramework/Sources/HttpServer/HttpContentNegociation.h Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/HttpServer/HttpContentNegociation.h Fri May 30 10:30:04 2025 +0200 @@ -75,7 +75,7 @@ }; - struct Reference; + class Reference; typedef std::vector<std::string> Tokens; typedef std::list<Handler> Handlers;
--- a/OrthancFramework/Sources/MallocMemoryBuffer.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/MallocMemoryBuffer.cpp Fri May 30 10:30:04 2025 +0200 @@ -76,7 +76,7 @@ } buffer_ = buffer; - size_ = size; + size_ = static_cast<size_t>(size); free_ = freeFunction; if (size_ != 0 &&
--- a/OrthancFramework/Sources/SerializationToolbox.cpp Tue May 20 10:28:02 2025 +0200 +++ b/OrthancFramework/Sources/SerializationToolbox.cpp Fri May 30 10:30:04 2025 +0200 @@ -188,10 +188,11 @@ { ReadArrayOfStrings(target, arr); } - catch (OrthancException& ex) - { // more detailed error + catch (OrthancException&) + { + // more detailed error throw OrthancException(ErrorCode_BadFileFormat, - "List of strings expected in field: " + field); + "List of strings expected in field: " + field); } }