Fix GH-47: Check return value of gpgme_ctx_set_engine_info

This commit is contained in:
Jakub Zelenka 2025-02-15 13:33:01 +01:00
parent f1e00ddd48
commit f065c4b0ee
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4

10
gnupg.c
View file

@ -166,8 +166,14 @@ static void php_gnupg_this_make(PHPC_THIS_DECLARE(gnupg), zval *options TSRMLS_D
}
if (file_name != NULL || home_dir != NULL) {
gpgme_ctx_set_engine_info(
ctx, GPGME_PROTOCOL_OpenPGP, file_name, home_dir);
if (gpgme_ctx_set_engine_info(
ctx, GPGME_PROTOCOL_OpenPGP, file_name, home_dir) != GPG_ERR_NO_ERROR) {
zend_throw_exception(
zend_exception_get_default(TSRMLS_C),
(char*) "Setting engine info failed",
0 TSRMLS_CC
);
}
}
gpgme_set_armor(ctx, 1);
#if GPGME_VERSION_NUMBER >= 0x010400 /* GPGME >= 1.4.0 */