|
@@ -2636,6 +2636,19 @@ bool extract_tar(std::string const& outFileName,
|
|
|
static_cast<void>(localeRAII);
|
|
static_cast<void>(localeRAII);
|
|
|
struct archive* a = archive_read_new();
|
|
struct archive* a = archive_read_new();
|
|
|
struct archive* ext = archive_write_disk_new();
|
|
struct archive* ext = archive_write_disk_new();
|
|
|
|
|
+ if (extract) {
|
|
|
|
|
+ int flags = ARCHIVE_EXTRACT_SECURE_NODOTDOT |
|
|
|
|
|
+ ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS | ARCHIVE_EXTRACT_SECURE_SYMLINKS;
|
|
|
|
|
+ if (extractTimestamps == cmSystemTools::cmTarExtractTimestamps::Yes) {
|
|
|
|
|
+ flags |= ARCHIVE_EXTRACT_TIME;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (archive_write_disk_set_options(ext, flags) != ARCHIVE_OK) {
|
|
|
|
|
+ ArchiveError("Problem with archive_write_disk_set_options(): ", ext);
|
|
|
|
|
+ archive_write_free(ext);
|
|
|
|
|
+ archive_read_free(a);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
archive_read_support_filter_all(a);
|
|
archive_read_support_filter_all(a);
|
|
|
archive_read_support_format_all(a);
|
|
archive_read_support_format_all(a);
|
|
|
struct archive_entry* entry;
|
|
struct archive_entry* entry;
|
|
@@ -2687,14 +2700,6 @@ bool extract_tar(std::string const& outFileName,
|
|
|
cmSystemTools::Stdout(cmStrCat(cm_archive_entry_pathname(entry), '\n'));
|
|
cmSystemTools::Stdout(cmStrCat(cm_archive_entry_pathname(entry), '\n'));
|
|
|
}
|
|
}
|
|
|
if (extract) {
|
|
if (extract) {
|
|
|
- if (extractTimestamps == cmSystemTools::cmTarExtractTimestamps::Yes) {
|
|
|
|
|
- r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME);
|
|
|
|
|
- if (r != ARCHIVE_OK) {
|
|
|
|
|
- ArchiveError("Problem with archive_write_disk_set_options(): ", ext);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
r = archive_write_header(ext, entry);
|
|
r = archive_write_header(ext, entry);
|
|
|
if (r == ARCHIVE_OK) {
|
|
if (r == ARCHIVE_OK) {
|
|
|
if (!copy_data(a, ext)) {
|
|
if (!copy_data(a, ext)) {
|
|
@@ -2715,8 +2720,8 @@ bool extract_tar(std::string const& outFileName,
|
|
|
# endif
|
|
# endif
|
|
|
else {
|
|
else {
|
|
|
ArchiveError("Problem with archive_write_header(): ", ext);
|
|
ArchiveError("Problem with archive_write_header(): ", ext);
|
|
|
- cmSystemTools::Error("Current file: " +
|
|
|
|
|
- cm_archive_entry_pathname(entry));
|
|
|
|
|
|
|
+ cmSystemTools::Error(
|
|
|
|
|
+ cmStrCat("Current file:\n ", cm_archive_entry_pathname(entry)));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|