changeset 29:d0c769a39095 default tip

safeguard for 32bit architectures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 May 2025 10:30:19 +0200
parents 9dfe76cb26ea
children
files Sources/StorageArea.cpp
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Sources/StorageArea.cpp	Fri Jan 17 13:45:23 2025 +0100
+++ b/Sources/StorageArea.cpp	Fri May 30 10:30:19 2025 +0200
@@ -114,6 +114,11 @@
                          const void *content,
                          int64_t size)
 {
+  if (static_cast<int64_t>(static_cast<size_t>(size)) != size)
+  {
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Buffer larger than 4GB, which is too large for Orthanc running in 32bits");
+  }
+
   boost::filesystem::path path = GetPathInternal(root_, uuid);
 
   if (boost::filesystem::exists(path.parent_path()))
@@ -131,7 +136,7 @@
     }
   }
       
-  Orthanc::SystemToolbox::WriteFile(content, size, path.string(), false);
+  Orthanc::SystemToolbox::WriteFile(content, static_cast<size_t>(size), path.string(), false);
 }