changeset 6761:f75c39296c83

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 May 2026 17:42:37 +0200
parents 6ebd2030e5a8 (current diff) 8fb371d94576 (diff)
children 78d2e3b2d40a
files
diffstat 27 files changed, 142 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/ThirdParty/base64/base64.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Resources/ThirdParty/base64/base64.cpp	Mon May 11 17:42:37 2026 +0200
@@ -1,7 +1,7 @@
 /* 
    base64.cpp and base64.h
 
-   Copyright (C) 2004-2008 René Nyffenegger
+   Copyright (C) 2004-2008 Ren� Nyffenegger
 
    This source code is provided 'as-is', without any express or implied
    warranty. In no event will the author be held liable for any damages
@@ -21,7 +21,7 @@
 
    3. This notice may not be removed or altered from any source distribution.
 
-   René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+   Ren� Nyffenegger rene.nyffenegger@adp-gmbh.ch
 
    ------------------------------
    This version has been modified (changed the interface + use another decoding algorithm
@@ -43,8 +43,12 @@
 
 void base64_encode(std::string& result, const std::string& stringToEncode)
 {
-  const unsigned char* bytes_to_encode = reinterpret_cast<const unsigned char*>
-      (stringToEncode.size() > 0 ? &stringToEncode[0] : NULL);
+  if (stringToEncode.size() == 0)
+  {
+    return;
+  }
+
+  const unsigned char* bytes_to_encode = reinterpret_cast<const unsigned char*>(stringToEncode.c_str());
   size_t in_len = stringToEncode.size();
   
   result.reserve(result.size() + in_len * 4 / 3 + 10);
@@ -87,7 +91,7 @@
   }
 }
 
-// old code from René Nyffenegger.  This code is slower
+// old code from Ren� Nyffenegger.  This code is slower
 void base64_decode_old(std::string& result, const std::string& encoded_string) {
   size_t in_len = encoded_string.size();
   int i = 0;
@@ -101,14 +105,14 @@
     char_array_4[i++] = encoded_string[in_]; in_++;
     if (i ==4) {
       for (i = 0; i <4; i++)
-        char_array_4[i] = base64_chars.find(char_array_4[i]);
+        char_array_4[i] = base64_chars.find(static_cast<char>(char_array_4[i]));
 
       char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
       char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
       char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
 
       for (i = 0; (i < 3); i++)
-        result += char_array_3[i];
+        result += static_cast<char>(char_array_3[i]);
       i = 0;
     }
   }
@@ -118,14 +122,14 @@
       char_array_4[j] = 0;
 
     for (j = 0; j <4; j++)
-      char_array_4[j] = base64_chars.find(char_array_4[j]);
+      char_array_4[j] = base64_chars.find(static_cast<char>(char_array_4[j]));
 
     char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
     char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
     char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
 
     for (j = 0; (j < i - 1); j++)
-      result += char_array_3[j];
+      result += static_cast<char>(char_array_3[j]);
   }
 }
 
@@ -166,7 +170,7 @@
   int val=0, valb=-8;
   for (std::string::const_iterator c = stringToDecode.begin(); c != stringToDecode.end(); ++c)
   {
-    size_t index = static_cast<size_t>(*c);
+    size_t index = static_cast<size_t>(static_cast<unsigned char>(*c));
     if (decode_indexes[index] == -1)
       break;
     val = (val<<6) + decode_indexes[index];
--- a/OrthancFramework/Sources/DicomNetworking/DicomAssociationParameters.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomAssociationParameters.cpp	Mon May 11 17:42:37 2026 +0200
@@ -343,7 +343,7 @@
 
       result.remote_ = RemoteModalityParameters(serialized[REMOTE]);
       result.localAet_ = SerializationToolbox::ReadString(serialized, LOCAL_AET);
-      result.timeout_ = SerializationToolbox::ReadInteger(serialized, TIMEOUT, GetDefaultTimeout());
+      result.timeout_ = SerializationToolbox::ReadUnsignedInteger(serialized, TIMEOUT, GetDefaultTimeout());
 
       // The calls to "isMember()" below are for compatibility with Orthanc <= 1.8.2 serialization
       if (serialized.isMember(MAXIMUM_PDU_LENGTH))
--- a/OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.cpp	Mon May 11 17:42:37 2026 +0200
@@ -178,7 +178,7 @@
       else
       {
         // Check out "dcmjpeg/apps/dcmcjpeg.cc"
-        DJ_RPLossy parameters(lossyQuality);
+        DJ_RPLossy parameters(static_cast<int>(lossyQuality));
           
         if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess1, &parameters))
         {
@@ -205,7 +205,7 @@
       else
       {
         // Check out "dcmjpeg/apps/dcmcjpeg.cc"
-        DJ_RPLossy parameters(lossyQuality);
+        DJ_RPLossy parameters(static_cast<int>(lossyQuality));
         if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess2_4, &parameters))
         {
           fixer.Apply(dicom);
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon May 11 17:42:37 2026 +0200
@@ -301,7 +301,7 @@
       return ss.str();
     }
 
-    
+    // NOLINTBEGIN(bugprone-macro-parentheses)
 #define DCMTK_TO_CTYPE_CONVERTER(converter, cType, dcmtkType, getter, toStringFunction) \
                                                                         \
     struct converter                                                    \
@@ -322,6 +322,7 @@
         return toStringFunction(value);                                 \
       }                                                                 \
     };
+    // NOLINTEND(bugprone-macro-parentheses)
 
     DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint32Converter, Sint32, DcmSignedLong, getSint32, boost::lexical_cast<std::string>)
     DCMTK_TO_CTYPE_CONVERTER(DcmtkToSint16Converter, Sint16, DcmSignedShort, getSint16, boost::lexical_cast<std::string>)
@@ -784,7 +785,7 @@
             // "SpecificCharacterSet" tag, if present. This branch is
             // new in Orthanc 1.9.1 (cf. DICOM CP 246).
             const std::string s(reinterpret_cast<const char*>(data), length);
-            const std::string utf8 = Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions, Convert(element.getVR()));
+            const std::string utf8 = Toolbox::ConvertDicomStringToUtf8(s, encoding, hasCodeExtensions, Convert(element.getVR()));
             return CreateValueFromUtf8String(GetTag(element), utf8, maxStringLength, ignoreTagLength);
           }
         }
@@ -2611,7 +2612,7 @@
     DcmInputBufferStream is;
     if (size > 0)
     {
-      is.setBuffer(buffer, size);
+      is.setBuffer(buffer, static_cast<offile_off_t>(size));
     }
     is.setEos();
 
@@ -2701,7 +2702,7 @@
               element->getString(c).good() && 
               c != NULL)
           {
-            std::string a = Toolbox::ConvertToUtf8(c, source, hasSourceCodeExtensions, Convert(element->getVR()));
+            std::string a = Toolbox::ConvertDicomStringToUtf8(c, source, hasSourceCodeExtensions, Convert(element->getVR()));
             std::string b = Toolbox::ConvertFromUtf8(a, target);
             element->putString(b.c_str());
           }
--- a/OrthancFramework/Sources/DicomParsing/Internals/DicomFrameIndex.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomFrameIndex.cpp	Mon May 11 17:42:37 2026 +0200
@@ -29,10 +29,9 @@
 #include "../../DicomFormat/DicomImageInformation.h"
 #include "../FromDcmtkBridge.h"
 #include "../../Endianness.h"
+#include "../../SerializationToolbox.h"
 #include "DicomImageDecoder.h"
 
-#include <boost/lexical_cast.hpp>
-
 #include <dcmtk/dcmdata/dcdeftag.h>
 #include <dcmtk/dcmdata/dcpxitem.h>
 #include <dcmtk/dcmdata/dcpixseq.h>
@@ -378,22 +377,15 @@
       return 1;
     }
 
-    int count = -1;
-    try
+    unsigned int count = 0;
+
+    if (SerializationToolbox::ParseUnsignedInteger(count, tmp))
     {
-      count = boost::lexical_cast<int>(tmp);
-    }
-    catch (boost::bad_lexical_cast&)
-    {
-    }
-
-    if (count < 0)
-    {
-      throw OrthancException(ErrorCode_BadFileFormat);        
+      return count;
     }
     else
     {
-      return static_cast<unsigned int>(count);
+      throw OrthancException(ErrorCode_BadFileFormat, "Invalid number of frames");
     }
   }
 
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Mon May 11 17:42:37 2026 +0200
@@ -346,8 +346,12 @@
         return true;
       }
 
-
-      unsigned int block = boost::lexical_cast<unsigned int>(*blockUri);
+      unsigned int block;
+      
+      if (!SerializationToolbox::ParseUnsignedInteger(block, *blockUri))
+      {
+        throw OrthancException(ErrorCode_BadFileFormat, "Invalid Block URI: not a number");
+      }
 
       if (block < GetPixelDataBlockCount(pixelData, transferSyntax))
       {
@@ -385,13 +389,9 @@
         }
       }
     }
-    catch (boost::bad_lexical_cast&)
-    {
-      // The URI entered by the user is not a number
-    }
     catch (std::bad_cast&)
     {
-      // This should never happen
+      throw OrthancException(ErrorCode_InternalError); // This should never happen / but I don't know why this std::bad_cast has been introduced (probably a std::bad_cast from DCMTK)
     }
 
     return false;
@@ -453,12 +453,8 @@
     // Go down in the tag hierarchy according to the URI
     for (size_t pos = 0; pos < uri.size() / 2; pos++)
     {
-      size_t index;
-      try
-      {
-        index = boost::lexical_cast<size_t>(uri[2 * pos + 1]);
-      }
-      catch (boost::bad_lexical_cast&)
+      unsigned int index;
+      if (!SerializationToolbox::ParseUnsignedInteger(index, uri[2 * pos + 1]))
       {
         return;
       }
@@ -466,7 +462,7 @@
       DcmTagKey k;
       DcmItem *child = NULL;
       ParseTagAndGroup(k, uri[2 * pos]);
-      if (!dicom->findAndGetSequenceItem(k, child, index).good() ||
+      if (!dicom->findAndGetSequenceItem(k, child, static_cast<signed long>(index)).good() ||
           child == NULL)
       {
         return;
--- a/OrthancFramework/Sources/FileBuffer.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/FileBuffer.cpp	Mon May 11 17:42:37 2026 +0200
@@ -29,6 +29,8 @@
 #include "OrthancException.h"
 
 #include <boost/filesystem/fstream.hpp>
+#include <boost/lexical_cast.hpp>
+#include <limits>
 
 
 namespace Orthanc
@@ -69,7 +71,12 @@
 
       if (size > 0)
       {
-        stream_.write(buffer, size);
+        if (size > static_cast<size_t>(std::numeric_limits<std::streamsize>::max()))
+        {
+          throw OrthancException(ErrorCode_CannotWriteFile, "Append buffer too large " + boost::lexical_cast<std::string>(size));
+        }
+
+        stream_.write(buffer, static_cast<std::streamsize>(size));
         if (!stream_.good())
         {
           stream_.close();
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Mon May 11 17:42:37 2026 +0200
@@ -119,7 +119,7 @@
         range.resize(static_cast<size_t>(size));
         assert(!range.empty());
 
-        memcpy(&range[0], &found->second[start], range.size());
+        memcpy(&range[0], &found->second[start], range.size()); // NOLINT(bugprone-undefined-memory-manipulation)
         
         return StringMemoryBuffer::CreateFromSwap(range);
       }
--- a/OrthancFramework/Sources/HttpServer/HttpOutput.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpOutput.cpp	Mon May 11 17:42:37 2026 +0200
@@ -802,7 +802,7 @@
       std::string header = "--" + multipartBoundary_ + "--\r\n";
       stream_.Send(false, header.c_str(), header.size());
     }
-    catch (OrthancException&)
+    catch (OrthancException&) //NOLINT(bugprone-empty-catch)
     {
     }
 
--- a/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Mon May 11 17:42:37 2026 +0200
@@ -1695,7 +1695,7 @@
             server->GetExceptionFormatter()->Format(output, e, method, requestUri);
           }
         }
-        catch (OrthancException&)
+        catch (OrthancException&) // NOLINT(bugprone-empty-catch)
         {
           // An exception here reflects the fact that the status code
           // was already set by the HTTP handler.
--- a/OrthancFramework/Sources/Logging.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Mon May 11 17:42:37 2026 +0200
@@ -40,6 +40,8 @@
  * Common section
  *********************************************************/
 
+//  NOLINTBEGIN(bugprone-reserved-identifier) // for all identifiers starting with _Orthanc
+
 namespace Orthanc
 {
   namespace Logging
@@ -1165,5 +1167,5 @@
   }
 }
 
-
 #endif   // ORTHANC_ENABLE_LOGGING
+//  NOLINTEND(bugprone-reserved-identifier)
\ No newline at end of file
--- a/OrthancFramework/Sources/MultiThreading/RunnableWorkersPool.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/MultiThreading/RunnableWorkersPool.cpp	Mon May 11 17:42:37 2026 +0200
@@ -174,7 +174,7 @@
     std::unique_ptr<MetricsRegistry::SharedMetrics> availableWorkers(
       new MetricsRegistry::SharedMetrics(registry, availableWorkersMetricsName, MetricsUpdatePolicy_MinOver10Seconds));
 
-    availableWorkers->Add(countWorkers); // mark all workers as available
+    availableWorkers->Add(static_cast<int64_t>(countWorkers)); // mark all workers as available in the metrics
 
     Start(countWorkers, baseThreadName, availableWorkers.release());
   }
--- a/OrthancFramework/Sources/SQLite/Connection.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/SQLite/Connection.cpp	Mon May 11 17:42:37 2026 +0200
@@ -382,7 +382,7 @@
     {
       int err = sqlite3_create_function_v2(db_, 
                                            func->GetName(), 
-                                           func->GetCardinality(),
+                                           static_cast<int>(func->GetCardinality()),
                                            SQLITE_UTF8, 
                                            func,
                                            ScalarFunctionCaller,
--- a/OrthancFramework/Sources/SerializationToolbox.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/SerializationToolbox.cpp	Mon May 11 17:42:37 2026 +0200
@@ -33,6 +33,7 @@
 #endif
 
 #include <boost/lexical_cast.hpp>
+#include <limits>
 
 
 namespace Orthanc
@@ -92,16 +93,21 @@
                                         const std::string& field)
   {
     if (value.type() != Json::objectValue ||
-        !value.isMember(field.c_str()) ||
-        (value[field.c_str()].type() != Json::intValue &&
-         value[field.c_str()].type() != Json::uintValue))
+        !value.isMember(field) ||
+        (value[field].type() != Json::intValue &&
+         value[field].type() != Json::uintValue))
     {
       throw OrthancException(ErrorCode_BadFileFormat,
                              "Integer value expected in field: " + field);
     }
     else
     {
-      return value[field.c_str()].asInt();
+      int64_t v64 = value[field].asInt64();
+      if (v64 > static_cast<int64_t>(std::numeric_limits<int>::max()))
+      {
+        throw OrthancException(ErrorCode_BadParameterType, "Value too large to fit in an integer in field '" + field + "'"); 
+      }
+      return static_cast<int>(v64);
     }    
   }
 
@@ -124,17 +130,25 @@
   unsigned int SerializationToolbox::ReadUnsignedInteger(const Json::Value& value,
                                                          const std::string& field)
   {
-    int tmp = ReadInteger(value, field);
-
-    if (tmp < 0)
+    if (value.type() != Json::objectValue ||
+        !value.isMember(field) ||
+        (value[field].type() != Json::intValue &&
+         value[field].type() != Json::uintValue))
     {
       throw OrthancException(ErrorCode_BadFileFormat,
-                             "Unsigned integer value expected in field: " + field);
+                             "Integer value expected in field: " + field);
     }
     else
     {
-      return static_cast<unsigned int>(tmp);
-    }
+      int64_t v64 = value[field].asInt64();
+
+      if (v64 < 0)
+      {
+        throw OrthancException(ErrorCode_BadParameterType, "Negative value found while expecting an unsigned int in field '" + field + "'"); 
+      }
+
+      return static_cast<unsigned int>(v64);
+    }    
   }
 
 
@@ -621,7 +635,14 @@
   {
     return ParseValue<uint64_t, false>(target, source);
   }
+
   
+  bool SerializationToolbox::ParseUnsignedInteger(unsigned int& target,
+                                                  const std::string& source)
+  {
+    return ParseValue<unsigned int, false>(target, source);
+  }
+
 
   bool SerializationToolbox::ParseFloat(float& target,
                                         const std::string& source)
--- a/OrthancFramework/Sources/SerializationToolbox.h	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/Sources/SerializationToolbox.h	Mon May 11 17:42:37 2026 +0200
@@ -130,6 +130,9 @@
     static bool ParseInteger64(int64_t& result,
                                const std::string& value);
 
+    static bool ParseUnsignedInteger(unsigned int& result,
+                                     const std::string& value);
+
     static bool ParseUnsignedInteger32(uint32_t& result,
                                        const std::string& value);
 
--- a/OrthancFramework/UnitTestsSources/FrameworkTests.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/UnitTestsSources/FrameworkTests.cpp	Mon May 11 17:42:37 2026 +0200
@@ -552,7 +552,7 @@
 }
 
 
-static int32_t GetUnicode(const uint8_t* data,
+static uint32_t GetUnicode(const uint8_t* data,
                           size_t size,
                           size_t expectedLength)
 {
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Mon May 11 17:42:37 2026 +0200
@@ -1381,7 +1381,7 @@
     Float32 u;
     ASSERT_TRUE(f.GetDcmtkObject().getDataset()->findAndGetFloat32(DCM_ExaminedBodyThickness, u).good());
     ASSERT_FLOAT_EQ(u, v);
-    ASSERT_TRUE(memcmp(&u, &v, 4) == 0);
+    ASSERT_TRUE(memcmp(&u, &v, 4) == 0);  // NOLINT(bugprone-suspicious-memory-comparison)
   }
 
   {
@@ -1402,7 +1402,7 @@
     f.Apply(visitor);
     Float32 u = visitor.GetResult() ["00109431"]["Value"][0].asFloat();
     ASSERT_FLOAT_EQ(u, v);
-    ASSERT_TRUE(memcmp(&u, &v, 4) == 0);
+    ASSERT_TRUE(memcmp(&u, &v, 4) == 0);  // NOLINT(bugprone-suspicious-memory-comparison)
   }
 }
 
@@ -1578,7 +1578,7 @@
       throw OrthancException(ErrorCode_InternalError);
     }
 
-    result[i] = static_cast<uint8_t>(a * 16 + b);
+    result[i] = static_cast<char>(a * 16 + b);
   }
 
   return result;
@@ -3564,7 +3564,7 @@
   {
     DicomTransferSyntax a = (DicomTransferSyntax) i;
 
-    std::string path = (std::string(getenv("HOME")) +
+    std::string path = (std::string(getenv("HOME")) +                                     // NOLINT(clang-analyzer-cplusplus.StringChecker)
                         "/Subversion/orthanc-tests/Database/TransferSyntaxes/" +
                         std::string(GetTransferSyntaxUid(a)) + ".dcm");
     if (Orthanc::SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(path)))
@@ -3629,7 +3629,7 @@
     {
       DicomTransferSyntax a = (DicomTransferSyntax) i;
 
-      std::string path = (std::string(getenv("HOME")) +
+      std::string path = (std::string(getenv("HOME")) +                                 // NOLINT(clang-analyzer-cplusplus.StringChecker)
                           "/Subversion/orthanc-tests/Database/TransferSyntaxes/" +
                           std::string(GetTransferSyntaxUid(a)) + ".dcm");
       if (Orthanc::SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(path)))
@@ -3668,7 +3668,7 @@
 
   {
     std::string source;
-    Orthanc::SystemToolbox::ReadFile(source, std::string(getenv("HOME")) +
+    Orthanc::SystemToolbox::ReadFile(source, std::string(getenv("HOME")) +                        // NOLINT(clang-analyzer-cplusplus.StringChecker)
                                      "/Subversion/orthanc-tests/Database/KarstenHilbertRF.dcm");
     toto.reset(FromDcmtkBridge::LoadFromMemoryBuffer(source.c_str(), source.size()));
   }
--- a/OrthancFramework/UnitTestsSources/JobsTests.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp	Mon May 11 17:42:37 2026 +0200
@@ -1722,6 +1722,18 @@
 TEST(SerializationToolbox, Numbers)
 {
   {
+    Json::Value v;
+
+    v["field"] = -1;
+    ASSERT_THROW(SerializationToolbox::ReadUnsignedInteger(v, "field"), OrthancException);
+    ASSERT_EQ(-1, SerializationToolbox::ReadInteger(v, "field"));
+
+    v["field"] = Json::Value(3000000000ul);
+    ASSERT_THROW(SerializationToolbox::ReadInteger(v, "field"), OrthancException);
+    ASSERT_EQ(3000000000ul, SerializationToolbox::ReadUnsignedInteger(v, "field"));
+  }
+
+  {
     int32_t i;
     ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, ""));
     ASSERT_FALSE(SerializationToolbox::ParseInteger32(i, "ee"));
--- a/OrthancFramework/UnitTestsSources/ToolboxTests.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancFramework/UnitTestsSources/ToolboxTests.cpp	Mon May 11 17:42:37 2026 +0200
@@ -110,7 +110,7 @@
     toEncode.clear();
     toEncode.reserve(size);
     for (size_t i = 0; i < size; i++)
-      toEncode.push_back(i % 256);
+      toEncode.push_back(static_cast<char>(i % 256));
 
     Toolbox::EncodeBase64(base64Result, toEncode);
     Toolbox::DecodeBase64(decodedResult, base64Result);
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon May 11 17:42:37 2026 +0200
@@ -27,6 +27,7 @@
 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
 #include "../../../OrthancFramework/Sources/Logging.h"
 #include "../../../OrthancFramework/Sources/SQLite/Transaction.h"
+#include "../../../OrthancFramework/Sources/SerializationToolbox.h"
 #include "../Search/ISqlLookupFormatter.h"
 #include "../ServerToolbox.h"
 #include "Compatibility/GenericFind.h"
@@ -153,7 +154,7 @@
 
     void Bind(SQLite::Statement& statement) const
     {
-      size_t pos = 0;
+      int pos = 0;
       
       for (std::list<std::string>::const_iterator
              it = values_.begin(); it != values_.end(); ++it, pos++)
@@ -431,12 +432,12 @@
       s.BindInt64(0, id);
       s.BindInt(1, attachment.GetContentType());
       s.BindString(2, attachment.GetUuid());
-      s.BindInt64(3, attachment.GetCompressedSize());
-      s.BindInt64(4, attachment.GetUncompressedSize());
-      s.BindInt(5, attachment.GetCompressionType());
+      s.BindInt64(3, static_cast<int64_t>(attachment.GetCompressedSize()));
+      s.BindInt64(4, static_cast<int64_t>(attachment.GetUncompressedSize()));
+      s.BindInt(5, static_cast<int>(attachment.GetCompressionType()));
       s.BindString(6, attachment.GetUncompressedMD5());
       s.BindString(7, attachment.GetCompressedMD5());
-      s.BindInt(8, revision);
+      s.BindInt(8, static_cast<int>(revision));
       s.BindBlob(9, attachment.GetCustomData());
       s.Run();
     }
@@ -1540,7 +1541,7 @@
         s.BindInt64(paramCounter++, to);
       }
 
-      s.BindInt(paramCounter++, limit + 1); // we take limit+1 because we use the +1 to know if "Done" must be set to true
+      s.BindInt(paramCounter++, static_cast<int>(limit) + 1); // we take limit+1 because we use the +1 to know if "Done" must be set to true
       GetChangesInternal(target, done, s, limit, returnFirstResults);
     }
 
@@ -1593,7 +1594,7 @@
       SQLite::Statement s(db_, SQLITE_FROM_HERE, 
                           "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?");
       s.BindInt64(0, since);
-      s.BindInt(1, limit + 1);
+      s.BindInt(1, static_cast<int>(limit) + 1);
       GetExportedResourcesInternal(target, done, s, limit);
     }
 
@@ -2085,7 +2086,7 @@
       s.BindInt64(0, id);
       s.BindInt(1, type);
       s.BindString(2, value);
-      s.BindInt(3, revision);
+      s.BindInt(3, static_cast<int>(revision));
       s.Run();
     }
 
@@ -2243,7 +2244,7 @@
                                 const std::string& from /* only used if "first == false" */,
                                 uint64_t limit) ORTHANC_OVERRIDE
     {
-      int64_t actualLimit = limit;
+      int64_t actualLimit = static_cast<int64_t>(limit);
       if (limit == 0)
       {
         actualLimit = -1;  // In SQLite, "if negative, there is no upper bound on the number of rows returned"
@@ -2372,7 +2373,7 @@
       {
         SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Queues WHERE queueId=? AND id=?");
         s.BindString(0, queueId);  // Providing "queueId" is just a safeguard
-        s.BindInt64(1, valueId);
+        s.BindInt64(1, static_cast<int64_t>(valueId));
         s.Run();
 
         if (db_.GetLastChangeCount() != 1)
@@ -2414,7 +2415,7 @@
         const int64_t reservedUntil = GetSecondsSinceEpoch() /* now */ + releaseTimeout;
         s.BindInt64(0, reservedUntil);
         s.BindString(1, queueId);  // Providing "queueId" is just a safeguard
-        s.BindInt64(2, valueId);
+        s.BindInt64(2, static_cast<int64_t>(valueId));
         s.Run();
 
         if (db_.GetLastChangeCount() == 0)
@@ -2702,7 +2703,7 @@
     dbCapabilities_.SetFlushToDisk(true);
     dbCapabilities_.SetLabelsSupport(true);
     dbCapabilities_.SetHasExtendedChanges(true);
-    dbCapabilities_.SetHasFindSupport(HasIntegratedFind());
+    dbCapabilities_.SetHasFindSupport(SQLiteDatabaseWrapper::HasIntegratedFind());
     dbCapabilities_.SetKeyValueStoresSupport(true);
     dbCapabilities_.SetQueuesSupport(true);
     dbCapabilities_.SetAttachmentCustomDataSupport(true);
@@ -2720,7 +2721,7 @@
     dbCapabilities_.SetFlushToDisk(true);
     dbCapabilities_.SetLabelsSupport(true);
     dbCapabilities_.SetHasExtendedChanges(true);
-    dbCapabilities_.SetHasFindSupport(HasIntegratedFind());
+    dbCapabilities_.SetHasFindSupport(SQLiteDatabaseWrapper::HasIntegratedFind());
     dbCapabilities_.SetKeyValueStoresSupport(true);
     dbCapabilities_.SetQueuesSupport(true);
     dbCapabilities_.SetAttachmentCustomDataSupport(true);
@@ -2812,16 +2813,8 @@
         tmp = "Unknown";
       }
 
-      bool ok = false;
-      try
-      {
-        LOG(INFO) << "Version of the Orthanc database: " << tmp;
-        version_ = boost::lexical_cast<unsigned int>(tmp);
-        ok = true;
-      }
-      catch (boost::bad_lexical_cast&)
-      {
-      }
+      LOG(INFO) << "Version of the Orthanc database: " << tmp;
+      bool ok = SerializationToolbox::ParseUnsignedInteger(version_, tmp);
 
       if (!ok)
       {
--- a/OrthancServer/Sources/OrthancInitialization.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/OrthancInitialization.cpp	Mon May 11 17:42:37 2026 +0200
@@ -404,7 +404,7 @@
     {
       // https://man7.org/linux/man-pages/man3/mallopt.3.html
       LOG(INFO) << "Calling mallopt(M_ARENA_MAX, " << maxArena << ")";
-      if (mallopt(M_ARENA_MAX, maxArena) != 1 /* success */)
+      if (mallopt(M_ARENA_MAX, static_cast<int>(maxArena)) != 1 /* success */)
       {
         throw OrthancException(ErrorCode_InternalError, "The call to mallopt(M_ARENA_MAX, " +
                                boost::lexical_cast<std::string>(maxArena) + ") has failed");
@@ -449,8 +449,9 @@
     {
       boost::filesystem::create_directories(indexDirectory);
     }
-    catch (boost::filesystem::filesystem_error&)
+    catch (boost::filesystem::filesystem_error& e)
     {
+      LOG(WARNING) << "Error encountered while creating IndexDirectory: " << e.what(); // the exception was ignored before 1.12.12; let's log it
     }
 
     return new SQLiteDatabaseWrapper(Orthanc::SystemToolbox::PathToUtf8(indexDirectory) + "/index");
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Mon May 11 17:42:37 2026 +0200
@@ -400,8 +400,9 @@
           return;
         }
       }
-      catch (OrthancException&)
+      catch (OrthancException&) // NOLINT(bugprone-empty-catch)
       {
+        // ignore any error when there is an accept header -> continue in normal mode to download the DICOM file
       }
     }
 
@@ -751,14 +752,10 @@
         std::string v = call.GetArgument("quality", "90" /* default JPEG quality */);
         bool ok = false;
 
-        try
+        if (SerializationToolbox::ParseUnsignedInteger(quality_, v))
         {
-          quality_ = boost::lexical_cast<unsigned int>(v);
           ok = (quality_ >= 1 && quality_ <= 100);
         }
-        catch (boost::bad_lexical_cast&)
-        {
-        }
 
         if (!ok)
         {
@@ -1865,19 +1862,15 @@
       std::string value = Toolbox::StripSpaces(found->second);
       Toolbox::RemoveSurroundingQuotes(value);
 
-      try
+      size_t comma = value.find('-');
+      if (comma != std::string::npos)
       {
-        size_t comma = value.find('-');
-        if (comma != std::string::npos)
+        if (SerializationToolbox::ParseInteger64(revision, value.substr(0, comma)))
         {
-          revision = boost::lexical_cast<int64_t>(value.substr(0, comma));
           md5 = value.substr(comma + 1);
           return true;
-        }        
-      }
-      catch (boost::bad_lexical_cast&)
-      {
-      }
+        }
+      }        
 
       throw OrthancException(ErrorCode_ParameterOutOfRange, "The \"" + header +
                              "\" HTTP header should contain the ETag (revision followed by MD5 hash), but found: " + value);
--- a/OrthancServer/Sources/OrthancWebDav.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/OrthancWebDav.cpp	Mon May 11 17:42:37 2026 +0200
@@ -1257,7 +1257,7 @@
             success = true;
           }
         }
-        catch (const OrthancException&)
+        catch (const OrthancException&) // NOLINT(bugprone-empty-catch)
         {
         }
       }
--- a/OrthancServer/Sources/ServerIndex.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/ServerIndex.cpp	Mon May 11 17:42:37 2026 +0200
@@ -460,14 +460,14 @@
   {
     Logging::ScopedThreadNameSetter setter("UNSTABLE-MON");
 
-    int stableAge;
+    unsigned int stableAge = 0;
     
     {
       OrthancConfiguration::ReaderLock lock;
       stableAge = lock.GetConfiguration().GetUnsignedIntegerParameter("StableAge", 60);
     }
 
-    if (stableAge <= 0)
+    if (stableAge <= 1)
     {
       stableAge = 60;
     }
--- a/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp	Mon May 11 17:42:37 2026 +0200
@@ -475,7 +475,7 @@
           context.GetIndex().LookupResourceType(level, *it);
           parentResources_[*it] = level;
         }
-        catch(...)
+        catch(...) // NOLINT(bugprone-empty-catch)
         {
           // ignore errors, the resource might have disappear
         }
--- a/OrthancServer/Sources/main.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/Sources/main.cpp	Mon May 11 17:42:37 2026 +0200
@@ -2268,7 +2268,7 @@
         boost::posix_time::ptime converted(boost::posix_time::from_time_t(creation));
         version += " (" + boost::posix_time::to_iso_string(converted) + ")";
       }
-      catch (...)
+      catch (...) // NOLINT(bugprone-empty-catch)
       {
       }
     }
--- a/OrthancServer/UnitTestsSources/ServerJobsTests.cpp	Mon May 11 17:42:21 2026 +0200
+++ b/OrthancServer/UnitTestsSources/ServerJobsTests.cpp	Mon May 11 17:42:37 2026 +0200
@@ -430,8 +430,8 @@
     operation.Serialize(s);
   }
 
-  ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException);
-  ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException);
+  ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
+  ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
 
   {
     std::unique_ptr<IJobOperation> operation;