Skip to content

Commit

Permalink
gh-886: ArcLite crash during an archive update
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Nov 27, 2024
1 parent 31bfc88 commit 80725d0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/arclite/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class Archive: public std::enable_shared_from_this<Archive> {
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<std::wstring>& file_names, const UpdateOptions& options, std::shared_ptr<ErrorLog> error_log);
void update(const std::wstring& src_dir, const std::vector<std::wstring>& file_names, const std::wstring& dst_dir, const UpdateOptions& options, std::shared_ptr<ErrorLog> error_log);
Expand Down
10 changes: 8 additions & 2 deletions plugins/arclite/attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<std::wstring> 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 };
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions plugins/arclite/changelog
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions plugins/arclite/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/arclite/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/arclite/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#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"
Expand Down

0 comments on commit 80725d0

Please sign in to comment.