From fb6692fc75da65b616a9a5ed66789c52e8227f97 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 22 Feb 2006 11:44:16 +0000 Subject: [PATCH] 2006-02-22 Marcus Brinkmann MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * engine.c (gpgme_engine_check_version): Reimplemented to allow checking the version correctly even after changing the engine information. Bug reported by Stéphane Corthésy. --- gpgme/ChangeLog | 4 ++++ gpgme/engine.c | 29 ++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 2911394..cf149c2 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5 +1,9 @@ 2006-02-22 Marcus Brinkmann + * engine.c (gpgme_engine_check_version): Reimplemented to allow + checking the version correctly even after changing the engine + information. Bug reported by Stéphane Corthésy. + * rungpg.c (read_colon_line): Invoke colon preprocess handler if it is set. (colon_preprocessor_t): New type. diff --git a/gpgme/engine.c b/gpgme/engine.c index a07fcdc..d975356 100644 --- a/gpgme/engine.c +++ b/gpgme/engine.c @@ -106,14 +106,33 @@ engine_get_req_version (gpgme_protocol_t proto) gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto) { + gpgme_error_t err; + gpgme_engine_info_t info; int result; - char *engine_version = engine_get_version (proto, NULL); - result = _gpgme_compare_versions (engine_version, - engine_get_req_version (proto)); - if (engine_version) - free (engine_version); + LOCK (engine_info_lock); + info = engine_info; + if (!info) + { + /* Make sure it is initialized. */ + UNLOCK (engine_info_lock); + err = gpgme_get_engine_info (&info); + if (err) + return err; + LOCK (engine_info_lock); + } + + while (info && info->protocol != proto) + info = info->next; + + if (!info) + result = 0; + else + result = _gpgme_compare_versions (info->version, + info->req_version); + + UNLOCK (engine_info_lock); return result ? 0 : gpg_error (GPG_ERR_INV_ENGINE); } -- 2.26.2