comparison OrthancFramework/Sources/Compression/ZipWriter.cpp @ 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 48b8dae6dc77
children f7adfb22e20e
comparison
equal deleted inserted replaced
5559:462b8f8a619c 5560:c80dbbae3f60
551 } 551 }
552 552
553 if (!pimpl_->file_) 553 if (!pimpl_->file_)
554 { 554 {
555 throw OrthancException(ErrorCode_CannotWriteFile, 555 throw OrthancException(ErrorCode_CannotWriteFile,
556 "Cannot create new ZIP archive: " + path_); 556 "Cannot create new ZIP archive"); // we do not log the path anymore since it can contain PHI
557 } 557 }
558 } 558 }
559 } 559 }
560 560
561 void ZipWriter::SetOutputPath(const char* path) 561 void ZipWriter::SetOutputPath(const char* path)
630 "", // Comment 630 "", // Comment
631 Z_DEFLATED, 631 Z_DEFLATED,
632 compressionLevel_); 632 compressionLevel_);
633 } 633 }
634 634
635 if (result != 0) 635 if (result != ZIP_OK)
636 { 636 {
637 throw OrthancException(ErrorCode_CannotWriteFile, 637 throw OrthancException(ErrorCode_CannotWriteFile,
638 "Cannot add new file inside ZIP archive: " + std::string(path)); 638 "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
639 } 639 }
640 640
641 hasFileInZip_ = true; 641 hasFileInZip_ = true;
642 } 642 }
643 643
664 664
665 while (length > 0) 665 while (length > 0)
666 { 666 {
667 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); 667 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep);
668 668
669 if (zipWriteInFileInZip(pimpl_->file_, p, bytes)) 669 int result = zipWriteInFileInZip(pimpl_->file_, p, bytes);
670 if (result != ZIP_OK)
670 { 671 {
671 throw OrthancException(ErrorCode_CannotWriteFile, 672 throw OrthancException(ErrorCode_CannotWriteFile,
672 "Cannot write data to ZIP archive: " + path_); 673 "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
673 } 674 }
674 675
675 p += bytes; 676 p += bytes;
676 length -= bytes; 677 length -= bytes;
677 } 678 }