changeset 6912:b929ccbda9e4

fix ReceivedCStoreInstanceFilter Lua callback whose return value was not taken into account
author Alain Mazy <am@orthanc.team>
date Tue, 02 Jun 2026 16:28:20 +0200
parents 31641dd2247a
children c149aa904805
files NEWS OrthancServer/Sources/LuaScripting.cpp
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Jun 02 15:40:29 2026 +0200
+++ b/NEWS	Tue Jun 02 16:28:20 2026 +0200
@@ -54,6 +54,7 @@
 * Fixed various OOB read/write (TODO: finalize release notes)
 * Upgraded dependencies for static builds:
   - dcmtk 3.7.0 hot-fix: https://github.com/DCMTK/dcmtk/commit/847d50e83ae5bbfbc731c99c142ee1410303d222
+* Lua: fix the "ReceivedCStoreInstanceFilter" Lua callback whose return value was not taken into account.
 
 
 Version 1.12.11 (2026-04-14)
--- a/OrthancServer/Sources/LuaScripting.cpp	Tue Jun 02 15:40:29 2026 +0200
+++ b/OrthancServer/Sources/LuaScripting.cpp	Tue Jun 02 16:28:20 2026 +0200
@@ -1057,7 +1057,7 @@
     return true;
   }
 
-  bool LuaScripting::FilterIncomingCStoreInstance(uint16_t& /*dimseStatus*/,
+  bool LuaScripting::FilterIncomingCStoreInstance(uint16_t& dimseStatus,
                                                   const DicomInstanceToStore& instance,
                                                   const Json::Value& simplified)
   {
@@ -1087,10 +1087,16 @@
 
       int result;
       call.ExecuteToInt(result);
-      return static_cast<uint16_t>(result);
+      if (result > 0xFFFF || result < 0)
+      {
+        throw OrthancException(ErrorCode_ParameterOutOfRange, "The returned DIMSE status should be >= 0 and <= 0xFFFF");
+      }
+
+      dimseStatus = static_cast<uint16_t>(result);
+      return dimseStatus == 0; // keep if DimseStatus is SUCCESS
     }
 
-    return true;
+    return true; // keep
   }