changeset 7143:9fc5589b40bc default tip

added more tolerance to invalid OW value representations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Aug 2026 08:41:04 +0200
parents df883e1f5d79
children
files NEWS OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Aug 31 08:21:57 2026 +0200
+++ b/NEWS	Mon Aug 31 08:41:04 2026 +0200
@@ -10,6 +10,7 @@
 -----------
 
 * Fixed a TCP socket leak when a DICOM association is received with an invalid calling AET.
+* Added more tolerance to invalid OW value representations
 * New CMake options: 
   - "THIRD_PARTY_DOWNLOADS_ROOT_URL" to specify another webserver to downloads the third-parties from.
   - "ORTHANC_SOURCES_DOWNLOADS_ROOT_URL" to specify another webserver to downloads the Orthanc sources from.
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Aug 31 08:21:57 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Aug 31 08:41:04 2026 +0200
@@ -1009,7 +1009,7 @@
         value = boost::lexical_cast<std::string>(content_[index]);
       }
 
-      void ReadArrayOfIntegers(std::vector<int64_t>& target) const
+      bool ReadArrayOfIntegers(std::vector<int64_t>& target) const
       {
         if (valid_)
         {
@@ -1018,10 +1018,11 @@
           {
             target[i] = content_[i];
           }
+          return true;
         }
         else
         {
-          throw OrthancException(ErrorCode_BadFileFormat);
+          return false;
         }
       }
     };
@@ -3922,8 +3923,15 @@
           {
             ValueRepresentationReader_OW reader(element);
             std::vector<int64_t> values;
-            reader.ReadArrayOfIntegers(values);
-            action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values);
+            if (reader.ReadArrayOfIntegers(values))
+            {
+              action = visitor.VisitIntegers(parentTags, parentIndexes, tag, vr, values);
+            }
+            else
+            {
+              LOG(INFO) << "Tag does not follow a valid OW value representation: " << tag.Format();
+              action = visitor.VisitNotSupported(parentTags, parentIndexes, tag, vr);
+            }
             break;
           }