From 80725d0e71f4be032e914dc3f34ec8f01489b629 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Wed, 27 Nov 2024 17:22:12 +0000 Subject: [PATCH] gh-886: ArcLite crash during an archive update --- plugins/arclite/archive.hpp | 2 +- plugins/arclite/attr.cpp | 10 ++++++++-- plugins/arclite/changelog | 5 +++++ plugins/arclite/plugin.cpp | 4 ++-- plugins/arclite/update.cpp | 2 +- plugins/arclite/version.hpp | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/arclite/archive.hpp b/plugins/arclite/archive.hpp index e5f5f528cd..06e399bff8 100644 --- a/plugins/arclite/archive.hpp +++ b/plugins/arclite/archive.hpp @@ -315,7 +315,7 @@ class Archive: public std::enable_shared_from_this { int m_open_password; bool m_update_props_defined; bool m_has_crc; - void load_update_props(); + void load_update_props(const ArcType& arc_type); public: void create(const std::wstring& src_dir, const std::vector& file_names, const UpdateOptions& options, std::shared_ptr error_log); void update(const std::wstring& src_dir, const std::vector& file_names, const std::wstring& dst_dir, const UpdateOptions& options, std::shared_ptr error_log); diff --git a/plugins/arclite/attr.cpp b/plugins/arclite/attr.cpp index 4708b69d74..066363d6f8 100644 --- a/plugins/arclite/attr.cpp +++ b/plugins/arclite/attr.cpp @@ -447,7 +447,7 @@ void Archive::load_arc_attr() { } } -void Archive::load_update_props() { +void Archive::load_update_props(const ArcType& arc_type) { if (m_update_props_defined) return; m_encrypted = false; @@ -463,7 +463,10 @@ void Archive::load_update_props() { m_level = (unsigned)-1; m_method.clear(); - if ((in_arc->GetArchiveProperty(kpidMethod, prop.ref()) == S_OK && prop.is_str()) || (in_arc->GetProperty(0, kpidMethod, prop.ref()) == S_OK && prop.is_str())) { + if (UInt32 NumberOfItems; + (in_arc->GetArchiveProperty(kpidMethod, prop.ref()) == S_OK && prop.is_str()) || + (in_arc->GetNumberOfItems(&NumberOfItems) && NumberOfItems && in_arc->GetProperty(0, kpidMethod, prop.ref()) == S_OK && prop.is_str()) + ) { std::list m_list = split(prop.get_str(), L' '); static const wchar_t *known_methods[] = { c_method_lzma, c_method_lzma2, c_method_ppmd, c_method_deflate, c_method_deflate64 }; @@ -487,6 +490,9 @@ void Archive::load_update_props() { break; } } + else if (arc_type == c_zip) { + m_method = c_method_deflate; + } if (m_level == (unsigned)-1) m_level = 7; // maximum diff --git a/plugins/arclite/changelog b/plugins/arclite/changelog index 1faba2d5bb..9149e7172d 100644 --- a/plugins/arclite/changelog +++ b/plugins/arclite/changelog @@ -1,3 +1,8 @@ +drkns 2024-11-27 17:23:01+00:00 - build 346 + +1. gh-886: ArcLite crash during an archive update. + Improve compression method detection when updating empty archives. + drkns 2024-09-15 14:00:02+01:00 - build 345 1. Improve compression method detection when updating archives. diff --git a/plugins/arclite/plugin.cpp b/plugins/arclite/plugin.cpp index 11e5fafb6a..a47e26076e 100644 --- a/plugins/arclite/plugin.cpp +++ b/plugins/arclite/plugin.cpp @@ -881,7 +881,7 @@ class Plugin FAIL_MSG(Far::get_msg(MSG_ERROR_UPDATE_UNSUPPORTED_FOR_SINGLEFILEARCHIVE)); } } - archive->load_update_props(); + archive->load_update_props(options.arc_type); options.method = archive->m_method; options.solid = archive->m_solid; options.encrypt = archive->m_encrypted; @@ -1127,7 +1127,7 @@ class Plugin archive->make_index(); options.arc_type = archive->arc_chain.back().type; - archive->load_update_props(); + archive->load_update_props(options.arc_type); if (!cmd.level_defined) options.level = archive->m_level; if (!cmd.method_defined) diff --git a/plugins/arclite/update.cpp b/plugins/arclite/update.cpp index 22c360274b..26e3d5dc90 100644 --- a/plugins/arclite/update.cpp +++ b/plugins/arclite/update.cpp @@ -1206,7 +1206,7 @@ void Archive::create_dir(const std::wstring& dir_name, const std::wstring& dst_d UpdateOptions options; options.arc_type = arc_chain.back().type; - load_update_props(); + load_update_props(options.arc_type); options.level = m_level; options.method = m_method; options.solid = m_solid; diff --git a/plugins/arclite/version.hpp b/plugins/arclite/version.hpp index 97424e19ff..65c26ed108 100644 --- a/plugins/arclite/version.hpp +++ b/plugins/arclite/version.hpp @@ -1,6 +1,6 @@ #include -#define PLUGIN_BUILD 345 +#define PLUGIN_BUILD 346 #define PLUGIN_DESC L"Archive support for Far Manager (based on 7-Zip project)" #define PLUGIN_NAME L"ArcLite" #define PLUGIN_FILENAME L"arclite.dll"