2006-02-22 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2006-02-22 11:44:16 +00:00
parent 2f4b385332
commit fb6692fc75
2 changed files with 28 additions and 5 deletions

View File

@ -1,5 +1,9 @@
2006-02-22 Marcus Brinkmann <marcus@g10code.de> 2006-02-22 Marcus Brinkmann <marcus@g10code.de>
* 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 * rungpg.c (read_colon_line): Invoke colon preprocess handler if
it is set. it is set.
(colon_preprocessor_t): New type. (colon_preprocessor_t): New type.

View File

@ -106,14 +106,33 @@ engine_get_req_version (gpgme_protocol_t proto)
gpgme_error_t gpgme_error_t
gpgme_engine_check_version (gpgme_protocol_t proto) gpgme_engine_check_version (gpgme_protocol_t proto)
{ {
gpgme_error_t err;
gpgme_engine_info_t info;
int result; int result;
char *engine_version = engine_get_version (proto, NULL);
result = _gpgme_compare_versions (engine_version, LOCK (engine_info_lock);
engine_get_req_version (proto)); info = engine_info;
if (engine_version) if (!info)
free (engine_version); {
/* 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); return result ? 0 : gpg_error (GPG_ERR_INV_ENGINE);
} }