changeset 1854:e2c3d752ee1a

prevent too long tags to be inserted
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2015 15:43:23 +0100
parents b7d3d3b182cf
children aa95aea0a352
files CMakeLists.txt OrthancServer/DicomInstanceToStore.cpp OrthancServer/FromDcmtkBridge.cpp OrthancServer/Internals/StoreScp.cpp
diffstat 4 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Dec 01 15:06:06 2015 +0100
+++ b/CMakeLists.txt	Tue Dec 01 15:43:23 2015 +0100
@@ -376,6 +376,7 @@
   -DORTHANC_VERSION="${ORTHANC_VERSION}"
   -DORTHANC_DATABASE_VERSION=${ORTHANC_DATABASE_VERSION}
   -DORTHANC_ENABLE_LOGGING=1
+  -DORTHANC_MAXIMUM_TAG_LENGTH=256
   )
 
 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
--- a/OrthancServer/DicomInstanceToStore.cpp	Tue Dec 01 15:06:06 2015 +0100
+++ b/OrthancServer/DicomInstanceToStore.cpp	Tue Dec 01 15:43:23 2015 +0100
@@ -114,7 +114,7 @@
                               *parsed_.GetContent().GetDcmtkObject().getDataset(),
                               DicomToJsonFormat_Full, 
                               DicomToJsonFlags_Default,
-                              256 /* max string length */);
+                              ORTHANC_MAXIMUM_TAG_LENGTH);
     }
   }
 
--- a/OrthancServer/FromDcmtkBridge.cpp	Tue Dec 01 15:06:06 2015 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Tue Dec 01 15:43:23 2015 +0100
@@ -376,7 +376,15 @@
       {
         std::string s(c);
         std::string utf8 = Toolbox::ConvertToUtf8(s, encoding);
-        return new DicomValue(utf8, false);
+
+        if (utf8.size() > ORTHANC_MAXIMUM_TAG_LENGTH)
+        {
+          return new DicomValue;  // Create a NULL value
+        }
+        else
+        {
+          return new DicomValue(utf8, false);
+        }
       }
     }
 
--- a/OrthancServer/Internals/StoreScp.cpp	Tue Dec 01 15:06:06 2015 +0100
+++ b/OrthancServer/Internals/StoreScp.cpp	Tue Dec 01 15:43:23 2015 +0100
@@ -171,7 +171,7 @@
             FromDcmtkBridge::ToJson(dicomJson, **imageDataSet,
                                     DicomToJsonFormat_Full, 
                                     DicomToJsonFlags_Default, 
-                                    256 /* max string length */);
+                                    ORTHANC_MAXIMUM_TAG_LENGTH);
 
             if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet))
             {