diff options
author | Brad King <brad.king@kitware.com> | 2021-08-20 15:23:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-08-20 15:23:20 (GMT) |
commit | 20fec1520458cdfb71bf1099cfc3648154d57d8f (patch) | |
tree | 2597bc6fb97dfbe86cdc41bd8efa7b0c97d2aebf /Source/CPack | |
parent | e2c06736e54d9160e49d5a67f5c10ca601ab31ed (diff) | |
download | CMake-20fec1520458cdfb71bf1099cfc3648154d57d8f.zip CMake-20fec1520458cdfb71bf1099cfc3648154d57d8f.tar.gz CMake-20fec1520458cdfb71bf1099cfc3648154d57d8f.tar.bz2 |
cmArchiveWrite: Check for construction errors on Open
Also update call sites to report the error.
Issue: #19666
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 5f0f153..829cef4 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -192,7 +192,13 @@ bool DebGenerator::generateDataTar() const cmArchiveWrite data_tar(fileStream_data_tar, this->TarCompressionType, this->DebianArchiveType, 0, static_cast<int>(this->NumThreads)); - data_tar.Open(); + if (!data_tar.Open()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error opening the archive \"" + << filename_data_tar + << "\", ERROR = " << data_tar.GetError() << std::endl); + return false; + } // uid/gid should be the one of the root user, and this root user has // always uid/gid equal to 0. @@ -317,7 +323,13 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const cmArchiveWrite control_tar(fileStream_control_tar, cmArchiveWrite::CompressGZip, this->DebianArchiveType); - control_tar.Open(); + if (!control_tar.Open()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error opening the archive \"" + << filename_control_tar + << "\", ERROR = " << control_tar.GetError() << std::endl); + return false; + } // sets permissions and uid/gid for the files control_tar.SetUIDAndGID(0u, 0u); @@ -457,7 +469,13 @@ bool DebGenerator::generateDeb() const cmGeneratedFileStream debStream; debStream.Open(outputPath, false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); - deb.Open(); + if (!deb.Open()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error opening the archive \"" + << outputPath << "\", ERROR = " << deb.GetError() + << std::endl); + return false; + } // uid/gid should be the one of the root user, and this root user has // always uid/gid equal to 0. |