diff options
author | saturneric <[email protected]> | 2024-08-05 16:55:32 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-08-05 16:55:32 +0000 |
commit | 795a81bd1edad59ef51e73157b5ad68cfa30e328 (patch) | |
tree | fd9c4da2f1389f0a236d806e005cabb9f5ceab41 /src/core | |
parent | fix: build pipeline (diff) | |
parent | fix: unchecking some check boxes at gnupg controller will not restart (diff) | |
download | GpgFrontend-2.1.4.tar.gz GpgFrontend-2.1.4.zip |
fix: according to issues and test, apply some fixesv2.1.4
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/core/GpgCoreInit.cpp | 14 | ||||
-rw-r--r-- | src/core/function/SecureMemoryAllocator.cpp | 30 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 10 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.h | 3 | ||||
-rw-r--r-- | src/core/thread/Task.cpp | 3 |
6 files changed, 20 insertions, 45 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 81c3f08f..90409e22 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -50,11 +50,6 @@ generate_export_header(gpgfrontend_core EXPORT_FILE_NAME "${_export_file}") # compile definitions target_compile_definitions(gpgfrontend_core PRIVATE GF_CORE_PRIVATE) -# mimalloc (except apple macos) -if(NOT APPLE) - target_link_libraries(gpgfrontend_core PUBLIC mimalloc) -endif() - # qt-aes target_sources(gpgfrontend_core PRIVATE ${CMAKE_SOURCE_DIR}/third_party/qt-aes/qaesencryption.cpp) diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 3f738835..68acc4cc 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -304,9 +304,6 @@ void InitGpgFrontendCore(CoreInitArgs args) { auto custom_key_database_path = settings.value("gnupg/custom_key_database_path", QString{}).toString(); - auto custom_gnupg_install_path = - settings.value("gnupg/custom_gnupg_install_path", QString{}).toString(); - auto use_pinentry_as_password_input_dialog = settings .value("gnupg/use_pinentry_as_password_input_dialog", @@ -327,10 +324,14 @@ void InitGpgFrontendCore(CoreInitArgs args) { !custom_key_database_path.isEmpty()) { if (VerifyKeyDatabasePath(QFileInfo(custom_key_database_path))) { key_database_fs_path = - QFileInfo(custom_gnupg_install_path).absoluteFilePath(); + QFileInfo(custom_key_database_path).absoluteFilePath(); + LOG_D() << "use custom gpg key database: " << key_database_fs_path + << "raw:" << custom_key_database_path; + } else { LOG_W() << "custom gpg key database path is not suitable: " - << key_database_fs_path; + << key_database_fs_path + << "raw:" << custom_key_database_path; } } else { @@ -354,8 +355,7 @@ void InitGpgFrontendCore(CoreInitArgs args) { // set custom gnupg path if (!gnupg_install_fs_path.isEmpty()) { - args.custom_gpgconf = true; - args.custom_gpgconf_path = gnupg_install_fs_path; + args.gpgconf_path = gnupg_install_fs_path; } args.offline_mode = forbid_all_gnupg_connection; diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp index c24e13f2..47301038 100644 --- a/src/core/function/SecureMemoryAllocator.cpp +++ b/src/core/function/SecureMemoryAllocator.cpp @@ -28,42 +28,22 @@ #include "SecureMemoryAllocator.h" -namespace GpgFrontend { +#include <cstdlib> -#if defined(__APPLE__) && defined(__MACH__) +namespace GpgFrontend { auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* { - auto* addr = malloc(size); + auto* addr = std::malloc(size); if (addr == nullptr) FLOG_F("malloc failed!"); return addr; } auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { - auto* addr = realloc(ptr, size); + auto* addr = std::realloc(ptr, size); if (addr == nullptr) FLOG_F("realloc failed!"); return addr; } -void SecureMemoryAllocator::Deallocate(void* p) { free(p); } - -#else - -#include <mimalloc.h> - -auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* { - auto* addr = mi_malloc(size); - if (addr == nullptr) FLOG_F("malloc failed!"); - return addr; -} - -auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { - auto* addr = mi_realloc(ptr, size); - if (addr == nullptr) FLOG_F("realloc memory failed!"); - return addr; -} - -void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); } - -#endif +void SecureMemoryAllocator::Deallocate(void* p) { std::free(p); } } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index 2d9c5992..a661f183 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -236,11 +236,10 @@ class GpgContext::Impl { const GpgContextInitArgs &args) -> bool { assert(ctx != nullptr); - if (args.custom_gpgconf && !args.custom_gpgconf_path.isEmpty()) { - LOG_D() << "set custom gpgconf path: " << args.custom_gpgconf_path; - auto err = - gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_GPGCONF, - args.custom_gpgconf_path.toUtf8(), nullptr); + if (!args.gpgconf_path.isEmpty()) { + LOG_D() << "set custom gpgconf path: " << args.gpgconf_path; + auto err = gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_GPGCONF, + args.gpgconf_path.toUtf8(), nullptr); if (CheckGpgError(err) != GPG_ERR_NO_ERROR) { LOG_W() << "set gpg context engine info error: " @@ -284,6 +283,7 @@ class GpgContext::Impl { // set custom gpg key db path if (!args_.db_path.isEmpty()) { + LOG_D() << "set context database path to" << args_.db_path; Module::UpsertRTValue("core", "gpgme.ctx.database_path", args_.db_path); } diff --git a/src/core/function/gpg/GpgContext.h b/src/core/function/gpg/GpgContext.h index 7a7ef24b..1ff22b8a 100644 --- a/src/core/function/gpg/GpgContext.h +++ b/src/core/function/gpg/GpgContext.h @@ -46,8 +46,7 @@ struct GpgContextInitArgs { bool offline_mode = false; ///< bool auto_import_missing_key = false; ///< - bool custom_gpgconf = false; ///< - QString custom_gpgconf_path; ///< + QString gpgconf_path; ///< bool use_pinentry = false; ///< }; diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp index 7a0e76e8..71c3f7b2 100644 --- a/src/core/thread/Task.cpp +++ b/src/core/thread/Task.cpp @@ -164,7 +164,8 @@ class Task::Impl { } }; -Task::Task(QString name) : p_(new Impl(this, name)) {} +Task::Task(QString name) + : p_(SecureCreateUniqueObject<Task::Impl>(this, name)) {} Task::Task(TaskRunnable runnable, QString name, DataObjectPtr data_object) : p_(SecureCreateUniqueObject<Impl>(this, runnable, name, data_object)) {} |