diff options
Diffstat (limited to '')
-rw-r--r-- | .github/workflows/release.yml | 6 | ||||
-rw-r--r-- | scripts/copyright_checking.py | 2 | ||||
-rw-r--r-- | src/core/function/ArchiveFileOperator.cpp | 12 | ||||
-rw-r--r-- | src/core/log/QtLoggerFmt.h | 6 | ||||
-rw-r--r-- | src/core/module/Module.cpp | 9 | ||||
-rw-r--r-- | src/core/module/Module.h | 2 | ||||
-rw-r--r-- | src/core/thread/Task.cpp | 2 | ||||
-rw-r--r-- | src/pinentry/pinentry.cpp | 197 | ||||
-rw-r--r-- | src/pinentry/pinentry.h | 4 |
9 files changed, 22 insertions, 218 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8cff5e43..925ac3fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,13 +4,13 @@ on: push: branches: [ main, 'develop' ] paths-ignore: - - 'resource/locale/template/**' + - 'resource/locale/**' - 'manual/**' - '**.md' pull_request: - branches: [ 'develop' ] + branches: [ main, 'develop' ] paths-ignore: - - 'resource/locale/template/**' + - 'resource/locale/**' - 'manual/**' - '**.md' diff --git a/scripts/copyright_checking.py b/scripts/copyright_checking.py index 82099b22..6002e0fe 100644 --- a/scripts/copyright_checking.py +++ b/scripts/copyright_checking.py @@ -63,13 +63,11 @@ def check_copright_by_path(path, copyright_text, suffix): file_path = os.path.join(root, file) with open(file_path, 'r', encoding='utf-8') as f: content = f.read() - if copyright_text not in content: print(f"copyright declaration missing: {file_path}") check_copright_by_path("src", copyright_text_source, ('.c', '.cpp', '.h', '.hpp')) check_copright_by_path("test", copyright_text_source, ('.c', '.cpp', '.h', '.hpp')) - check_copright_by_path("src", copyright_text_script, ('.txt')) check_copright_by_path("src", copyright_text_script, ('.txt')) print("check done")
\ No newline at end of file diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp index 54c78628..aad8b525 100644 --- a/src/core/function/ArchiveFileOperator.cpp +++ b/src/core/function/ArchiveFileOperator.cpp @@ -159,10 +159,22 @@ void ArchiveFileOperator::NewArchive2DataExchanger( auto fd = open(archive_entry_sourcepath(entry), O_RDONLY); auto len = read(fd, buff.data(), buff.size()); assert(len <= buff.size() && len > 0); + if (len == -1) { + GF_CORE_LOG_ERROR("read() failed, ret: {}, abort ...", r); + archive_entry_free(entry); + close(fd); + break; + } while (len > 0) { archive_write_data(archive, buff.data(), len); len = read(fd, buff.data(), buff.size()); assert(len <= buff.size() && len > 0); + if (len == -1) { + GF_CORE_LOG_ERROR("read() failed, ret: {}, abort ...", r); + archive_entry_free(entry); + close(fd); + break; + } } close(fd); } diff --git a/src/core/log/QtLoggerFmt.h b/src/core/log/QtLoggerFmt.h index 3cb38160..dbf97c64 100644 --- a/src/core/log/QtLoggerFmt.h +++ b/src/core/log/QtLoggerFmt.h @@ -32,11 +32,7 @@ template <> struct fmt::formatter<QString> { // Parses format specifications. constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - auto it = std::find(ctx.begin(), ctx.end(), '}'); - if (it != ctx.end() && *it != '}') { - throw fmt::format_error("invalid format specifier for QString"); - } - return it; + return ctx.begin(); } // Formats the QString qstr and writes it to the output. diff --git a/src/core/module/Module.cpp b/src/core/module/Module.cpp index c37b2262..9076dc2c 100644 --- a/src/core/module/Module.cpp +++ b/src/core/module/Module.cpp @@ -40,8 +40,7 @@ class Module::Impl { Impl(ModuleRawPtr m_ptr, ModuleIdentifier id, ModuleVersion version, ModuleMetaData meta_data) - : gpc_(nullptr), - m_ptr_(m_ptr), + : m_ptr_(m_ptr), identifier_(std::move(id)), version_(std::move(version)), meta_data_(std::move(meta_data)) {} @@ -49,7 +48,7 @@ class Module::Impl { auto GetChannel() -> int { return get_gpc()->GetChannel(m_ptr_); } auto GetDefaultChannel() -> int { - return get_gpc()->GetDefaultChannel(m_ptr_); + return GlobalModuleContext::GetDefaultChannel(m_ptr_); } auto GetTaskRunner() -> std::optional<TaskRunnerPtr> { @@ -67,7 +66,7 @@ class Module::Impl { void SetGPC(GlobalModuleContext* gpc) { gpc_ = gpc; } private: - GlobalModuleContext* gpc_; + GlobalModuleContext* gpc_{}; Module* m_ptr_; const ModuleIdentifier identifier_; const ModuleVersion version_; @@ -82,7 +81,7 @@ class Module::Impl { }; Module::Module(ModuleIdentifier id, ModuleVersion version, - ModuleMetaData meta_data) + const ModuleMetaData& meta_data) : p_(SecureCreateUniqueObject<Impl>(this, id, version, meta_data)) {} Module::~Module() = default; diff --git a/src/core/module/Module.h b/src/core/module/Module.h index 2742475e..2a5b54e7 100644 --- a/src/core/module/Module.h +++ b/src/core/module/Module.h @@ -47,7 +47,7 @@ using TaskRunnerPtr = std::shared_ptr<Thread::TaskRunner>; class GPGFRONTEND_CORE_EXPORT Module : public QObject { Q_OBJECT public: - Module(ModuleIdentifier, ModuleVersion, ModuleMetaData); + Module(ModuleIdentifier, ModuleVersion, const ModuleMetaData&); ~Module(); diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp index 1d251520..dc0cfe94 100644 --- a/src/core/thread/Task.cpp +++ b/src/core/thread/Task.cpp @@ -138,7 +138,7 @@ class Task::Impl { void init() { GF_CORE_LOG_TRACE("task {} created, parent: {}, impl: {}", name_, - (void *)parent_, (void *)this); + static_cast<void *>(parent_), static_cast<void *>(this)); // HoldOnLifeCycle(false); diff --git a/src/pinentry/pinentry.cpp b/src/pinentry/pinentry.cpp index 6168a203..c648aea6 100644 --- a/src/pinentry/pinentry.cpp +++ b/src/pinentry/pinentry.cpp @@ -232,48 +232,6 @@ static gpg_error_t pinentry_assuan_reset_handler(assuan_context_t ctx, return 0; } -/* Copy TEXT or TEXTLEN to BUFFER and escape as required. Return a - pointer to the end of the new buffer. Note that BUFFER must be - large enough to keep the entire text; allocataing it 3 times of - TEXTLEN is sufficient. */ -static char *copy_and_escape(char *buffer, const void *text, size_t textlen) { - int i; - const unsigned char *s = (unsigned char *)text; - char *p = buffer; - - for (i = 0; i < textlen; i++) { - if (s[i] < ' ' || s[i] == '+') { - snprintf(p, 4, "%%%02X", s[i]); - p += 3; - } else if (s[i] == ' ') - *p++ = '+'; - else - *p++ = s[i]; - } - return p; -} - -/* Perform percent unescaping in STRING and return the new valid length - of the string. A terminating Nul character is inserted at the end of - the unescaped string. - */ -static size_t do_unescape_inplace(char *s) { - unsigned char *p, *p0; - - p = p0 = (unsigned char *)s; - while (*s) { - if (*s == '%' && s[1] && s[2]) { - s++; - *p++ = xtoi_2(s); - s += 2; - } else - *p++ = *s++; - } - *p = 0; - - return (p - p0); -} - /* Return a malloced copy of the commandline for PID. If this is not * possible NULL is returned. */ #ifndef WINDOWS @@ -530,18 +488,6 @@ static struct assuan_malloc_hooks assuan_malloc_hooks = { GpgFrontend::SecureMalloc, GpgFrontend::SecureRealloc, GpgFrontend::SecureFree}; -/* Initialize the secure memory subsystem, drop privileges and return. - Must be called early. */ -void pinentry_init(const char *pgmname) { - /* Store away our name. */ - if (strlen(pgmname) > sizeof this_pgmname - 2) abort(); - strcpy(this_pgmname, pgmname); - - gpgrt_check_version(NULL); - - assuan_set_malloc_hooks(&assuan_malloc_hooks); -} - /* Simple test to check whether DISPLAY is set or the option --display was given. Used to decide whether the GUI or curses should be initialized. */ @@ -590,149 +536,6 @@ int pinentry_have_display(int argc, char **argv) { /* Set the optional flag used with getinfo. */ void pinentry_set_flavor_flag(const char *string) { flavor_flag = string; } -static gpg_error_t option_handler(assuan_context_t ctx, const char *key, - const char *value) { - (void)ctx; - - if (!strcmp(key, "no-grab") && !*value) - pinentry.grab = 0; - else if (!strcmp(key, "grab") && !*value) - pinentry.grab = 1; - else if (!strcmp(key, "debug-wait")) { -#ifndef WINDOWS - fprintf(stderr, "%s: waiting for debugger - my pid is %u ...\n", - this_pgmname, (unsigned int)getpid()); - sleep(*value ? atoi(value) : 5); - fprintf(stderr, "%s: ... okay\n", this_pgmname); -#endif - } else if (!strcmp(key, "display")) { - if (pinentry.display) free(pinentry.display); - pinentry.display = strdup(value); - if (!pinentry.display) return gpg_error_from_syserror(); - } else if (!strcmp(key, "ttyname")) { - if (pinentry.ttyname) free(pinentry.ttyname); - pinentry.ttyname = strdup(value); - if (!pinentry.ttyname) return gpg_error_from_syserror(); - } else if (!strcmp(key, "ttytype")) { - if (pinentry.ttytype_l) free(pinentry.ttytype_l); - pinentry.ttytype_l = strdup(value); - if (!pinentry.ttytype_l) return gpg_error_from_syserror(); - } else if (!strcmp(key, "ttyalert")) { - if (pinentry.ttyalert) free(pinentry.ttyalert); - pinentry.ttyalert = strdup(value); - if (!pinentry.ttyalert) return gpg_error_from_syserror(); - } else if (!strcmp(key, "lc-ctype")) { - if (pinentry.lc_ctype) free(pinentry.lc_ctype); - pinentry.lc_ctype = strdup(value); - if (!pinentry.lc_ctype) return gpg_error_from_syserror(); - } else if (!strcmp(key, "lc-messages")) { - if (pinentry.lc_messages) free(pinentry.lc_messages); - pinentry.lc_messages = strdup(value); - if (!pinentry.lc_messages) return gpg_error_from_syserror(); - } else if (!strcmp(key, "owner")) { - long along; - char *endp; - - free(pinentry.owner_host); - pinentry.owner_host = NULL; - pinentry.owner_uid = -1; - pinentry.owner_pid = 0; - - errno = 0; - along = strtol(value, &endp, 10); - if (along && !errno) { - pinentry.owner_pid = (unsigned long)along; - if (*endp) { - errno = 0; - if (*endp == '/') { /* we have a uid */ - endp++; - along = strtol(endp, &endp, 10); - if (along >= 0 && !errno) pinentry.owner_uid = (int)along; - } - if (endp) { - while (*endp == ' ') endp++; - if (*endp) { - pinentry.owner_host = strdup(endp); - for (endp = pinentry.owner_host; *endp && *endp != ' '; endp++) - ; - *endp = 0; - } - } - } - } - } else if (!strcmp(key, "parent-wid")) { - pinentry.parent_wid = atoi(value); - /* FIXME: Use strtol and add some error handling. */ - } else if (!strcmp(key, "touch-file")) { - if (pinentry.touch_file) free(pinentry.touch_file); - pinentry.touch_file = strdup(value); - if (!pinentry.touch_file) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-ok")) { - pinentry.default_ok = strdup(value); - if (!pinentry.default_ok) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-cancel")) { - pinentry.default_cancel = strdup(value); - if (!pinentry.default_cancel) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-prompt")) { - pinentry.default_prompt = strdup(value); - if (!pinentry.default_prompt) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-pwmngr")) { - pinentry.default_pwmngr = strdup(value); - if (!pinentry.default_pwmngr) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-cf-visi")) { - pinentry.default_cf_visi = strdup(value); - if (!pinentry.default_cf_visi) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-tt-visi")) { - pinentry.default_tt_visi = strdup(value); - if (!pinentry.default_tt_visi) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-tt-hide")) { - pinentry.default_tt_hide = strdup(value); - if (!pinentry.default_tt_hide) return gpg_error_from_syserror(); - } else if (!strcmp(key, "default-capshint")) { - pinentry.default_capshint = strdup(value); - if (!pinentry.default_capshint) return gpg_error_from_syserror(); - } else if (!strcmp(key, "allow-external-password-cache") && !*value) { - pinentry.allow_external_password_cache = 1; - pinentry.tried_password_cache = 0; - } else if (!strcmp(key, "allow-emacs-prompt") && !*value) { -#ifdef INSIDE_EMACS - pinentry_enable_emacs_cmd_handler(); -#endif - } else if (!strcmp(key, "invisible-char")) { - if (pinentry.invisible_char) free(pinentry.invisible_char); - pinentry.invisible_char = strdup(value); - if (!pinentry.invisible_char) return gpg_error_from_syserror(); - } else if (!strcmp(key, "formatted-passphrase") && !*value) { - pinentry.formatted_passphrase = 1; - } else if (!strcmp(key, "formatted-passphrase-hint")) { - if (pinentry.formatted_passphrase_hint) - free(pinentry.formatted_passphrase_hint); - pinentry.formatted_passphrase_hint = strdup(value); - if (!pinentry.formatted_passphrase_hint) return gpg_error_from_syserror(); - do_unescape_inplace(pinentry.formatted_passphrase_hint); - } else if (!strcmp(key, "constraints-enforce") && !*value) - pinentry.constraints_enforce = 1; - else if (!strcmp(key, "constraints-hint-short")) { - if (pinentry.constraints_hint_short) free(pinentry.constraints_hint_short); - pinentry.constraints_hint_short = strdup(value); - if (!pinentry.constraints_hint_short) return gpg_error_from_syserror(); - do_unescape_inplace(pinentry.constraints_hint_short); - } else if (!strcmp(key, "constraints-hint-long")) { - if (pinentry.constraints_hint_long) free(pinentry.constraints_hint_long); - pinentry.constraints_hint_long = strdup(value); - if (!pinentry.constraints_hint_long) return gpg_error_from_syserror(); - do_unescape_inplace(pinentry.constraints_hint_long); - } else if (!strcmp(key, "constraints-error-title")) { - if (pinentry.constraints_error_title) - free(pinentry.constraints_error_title); - pinentry.constraints_error_title = strdup(value); - if (!pinentry.constraints_error_title) return gpg_error_from_syserror(); - do_unescape_inplace(pinentry.constraints_error_title); - } else - return gpg_error(GPG_ERR_UNKNOWN_OPTION); - return 0; -} - /* Note, that it is sufficient to allocate the target string D as long as the source string S, i.e.: strlen(s)+1; */ static void strcpy_escaped(char *d, const char *s) { diff --git a/src/pinentry/pinentry.h b/src/pinentry/pinentry.h index 3a01a69e..143a8855 100644 --- a/src/pinentry/pinentry.h +++ b/src/pinentry/pinentry.h @@ -312,10 +312,6 @@ char *pinentry_inq_genpin(pinentry_t pin); PIN. Returns new buffer on success and 0 on failure. */ char *pinentry_setbufferlen(pinentry_t pin, int len); -/* Initialize the secure memory subsystem, drop privileges and - return. Must be called early. */ -void pinentry_init(const char *pgmname); - /* Return true if either DISPLAY is set or ARGV contains the string "--display". */ int pinentry_have_display(int argc, char **argv); |