From a48399f73b7ad932af88d63fb9956da8d1c6bcb7 Mon Sep 17 00:00:00 2001 From: Giovanni <561184+wargio@users.noreply.github.com> Date: Tue, 5 Apr 2022 11:35:45 +0200 Subject: [PATCH] Adds support for RZ_SIGDB path and fixes sorting on some columns (#2923) --- src/core/Cutter.cpp | 35 +++++++++++++++++++++++++---------- src/widgets/FlirtWidget.cpp | 4 ++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 4721ab4f..b11c5ebf 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -3054,19 +3054,10 @@ QList CutterCore::getAllHeaders() return ret; } -QList CutterCore::getSignaturesDB() +static void sigdb_insert_element_into_qlist(RzList *list, QList &sigdb) { - CORE_LOCK(); - QList sigdb; - const char *sigdb_path = rz_config_get(core->config, "flirt.sigdb.path"); - if (RZ_STR_ISEMPTY(sigdb_path)) { - return sigdb; - } - - RzList *list = rz_sign_sigdb_load_database(sigdb_path, true); void *ptr = NULL; RzListIter *iter = NULL; - rz_list_foreach(list, iter, ptr) { RzSigDBEntry *sig = static_cast(ptr); @@ -3081,6 +3072,30 @@ QList CutterCore::getSignaturesDB() flirt.arch_bits = QString::number(sig->arch_bits); sigdb << flirt; } + rz_list_free(list); +} + +QList CutterCore::getSignaturesDB() +{ + CORE_LOCK(); + QList sigdb; + RzList *list = nullptr; + + char *system_sigdb = rz_path_system(RZ_SIGDB); + if (RZ_STR_ISNOTEMPTY(system_sigdb) && rz_file_is_directory(system_sigdb)) { + list = rz_sign_sigdb_load_database(system_sigdb, true); + sigdb_insert_element_into_qlist(list, sigdb); + } + free(system_sigdb); + + const char *sigdb_path = rz_config_get(core->config, "flirt.sigdb.path"); + if (RZ_STR_ISEMPTY(sigdb_path)) { + return sigdb; + } + + list = rz_sign_sigdb_load_database(sigdb_path, true); + sigdb_insert_element_into_qlist(list, sigdb); + return sigdb; } diff --git a/src/widgets/FlirtWidget.cpp b/src/widgets/FlirtWidget.cpp index 61d43d87..874a63e3 100644 --- a/src/widgets/FlirtWidget.cpp +++ b/src/widgets/FlirtWidget.cpp @@ -107,9 +107,9 @@ bool FlirtProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right case FlirtModel::ArchNameColumn: return leftEntry.arch_name < rightEntry.arch_name; case FlirtModel::ArchBitsColumn: - return leftEntry.arch_bits < rightEntry.arch_bits; + return leftEntry.arch_bits.toULongLong() < rightEntry.arch_bits.toULongLong(); case FlirtModel::NumModulesColumn: - return leftEntry.n_modules < rightEntry.n_modules; + return leftEntry.n_modules.toULongLong() < rightEntry.n_modules.toULongLong(); case FlirtModel::NameColumn: return leftEntry.base_name < rightEntry.base_name; case FlirtModel::DetailsColumn: