diff options
author | Brad King <brad.king@kitware.com> | 2021-08-24 13:52:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-08-24 13:52:44 (GMT) |
commit | 4b613cd706d292db2b96d9482331f277dfe8b0dd (patch) | |
tree | 32671e24d23d917a97ad70af15acea91db812ee3 | |
parent | 56e242de240ab00c71cba279499a3bd17ba47362 (diff) | |
parent | 20fec1520458cdfb71bf1099cfc3648154d57d8f (diff) | |
download | CMake-4b613cd706d292db2b96d9482331f277dfe8b0dd.zip CMake-4b613cd706d292db2b96d9482331f277dfe8b0dd.tar.gz CMake-4b613cd706d292db2b96d9482331f277dfe8b0dd.tar.bz2 |
Merge topic 'archive-error-handling'
20fec15204 cmArchiveWrite: Check for construction errors on Open
e2c06736e5 libarchive: Add missing cm3p prefixes on includes
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6470
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 24 | ||||
-rw-r--r-- | Source/cmArchiveWrite.cxx | 3 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 5 | ||||
-rw-r--r-- | Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c | 2 | ||||
-rw-r--r-- | Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c | 4 |
5 files changed, 31 insertions, 7 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. diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 54b2998..9e0d80c 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -250,6 +250,9 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, bool cmArchiveWrite::Open() { + if (!this->Error.empty()) { + return false; + } if (archive_write_open( this->Archive, this, nullptr, reinterpret_cast<archive_write_callback*>(&Callback::Write), diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f082ae8..54fe7a1 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1629,7 +1629,10 @@ bool cmSystemTools::CreateTar(const std::string& outFileName, cmArchiveWrite a(fout, compress, format.empty() ? "paxr" : format, compressionLevel); - a.Open(); + if (!a.Open()) { + cmSystemTools::Error(a.GetError()); + return false; + } a.SetMTime(mtime); a.SetVerbose(verbose); bool tarCreatedSuccessfully = true; diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c index 9489e51..bcb67fe 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #elif HAVE_BSDXML_H #include <bsdxml.h> #elif HAVE_EXPAT_H -#include <expat.h> +#include <cm3p/expat.h> #endif #ifdef HAVE_BZLIB_H #include <cm3p/bzlib.h> diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c index 4d71f98..62f98a4 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c @@ -53,10 +53,10 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 #include <cm3p/zlib.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm3p/bzlib.h> #endif #ifdef HAVE_LZMA_H -#include <lzma.h> +#include <cm3p/lzma.h> #endif #include "archive.h" |