changeset 5560:c80dbbae3f60

Removed potential PHI from the logs when Orthanc encounters an error while creating a zip file
author Alain Mazy <am@orthanc.team>
date Mon, 22 Apr 2024 10:50:33 +0200
parents 462b8f8a619c
children 0b18690c1935
files NEWS OrthancFramework/Sources/Compression/ZipWriter.cpp
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Apr 22 10:39:33 2024 +0200
+++ b/NEWS	Mon Apr 22 10:50:33 2024 +0200
@@ -13,6 +13,9 @@
 * The 0x0111 DIMSE Status is now considered as a warning instead of an error
   when received as a response to a C-Store. 
   See https://discourse.orthanc-server.org/t/ignore-dimse-status-0x0111-when-sending-partial-duplicate-studies/4555/3
+* Removed potential PHI from the logs when Orthanc encounters an error while
+  creating a zip file.
+
 
 REST API
 --------
--- a/OrthancFramework/Sources/Compression/ZipWriter.cpp	Mon Apr 22 10:39:33 2024 +0200
+++ b/OrthancFramework/Sources/Compression/ZipWriter.cpp	Mon Apr 22 10:50:33 2024 +0200
@@ -553,7 +553,7 @@
       if (!pimpl_->file_)
       {
         throw OrthancException(ErrorCode_CannotWriteFile,
-                               "Cannot create new ZIP archive: " + path_);
+                               "Cannot create new ZIP archive");  // we do not log the path anymore since it can contain PHI
       }
     }
   }
@@ -632,10 +632,10 @@
                                    compressionLevel_);
     }
 
-    if (result != 0)
+    if (result != ZIP_OK)
     {
       throw OrthancException(ErrorCode_CannotWriteFile,
-                             "Cannot add new file inside ZIP archive: " + std::string(path));
+                             "Cannot add new file inside ZIP archive - error code = " + boost::lexical_cast<std::string>(result)); // we do not log the path anymore since it can contain PHI
     }
 
     hasFileInZip_ = true;
@@ -666,10 +666,11 @@
     {
       int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep);
 
-      if (zipWriteInFileInZip(pimpl_->file_, p, bytes))
+      int result = zipWriteInFileInZip(pimpl_->file_, p, bytes);
+      if (result != ZIP_OK)
       {
         throw OrthancException(ErrorCode_CannotWriteFile,
-                               "Cannot write data to ZIP archive: " + path_);
+                               "Cannot write data to ZIP archive - error code =" + boost::lexical_cast<std::string>(result));  // we do not log the path anymore since it can contain PHI
       }
       
       p += bytes;