mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 22:37:10 +00:00
Fix CS in gnupg_adddecryptkey and gnupg_addencryptkey
This commit is contained in:
parent
ee75e41714
commit
ba7bce32f7
1 changed files with 12 additions and 7 deletions
19
gnupg.c
19
gnupg.c
|
@ -979,14 +979,16 @@ PHP_FUNCTION(gnupg_adddecryptkey)
|
||||||
}
|
}
|
||||||
GNUPG_RES_FETCH();
|
GNUPG_RES_FETCH();
|
||||||
}
|
}
|
||||||
if ((PHPC_THIS->err = gpgme_get_key(PHPC_THIS->ctx, key_id, &gpgme_key, 1)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_get_key(PHPC_THIS->ctx, key_id, &gpgme_key, 1))) {
|
||||||
GNUPG_ERR("get_key failed");
|
GNUPG_ERR("get_key failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpgme_subkey = gpgme_key->subkeys;
|
gpgme_subkey = gpgme_key->subkeys;
|
||||||
while (gpgme_subkey) {
|
while (gpgme_subkey) {
|
||||||
if (gpgme_subkey->secret == 1) {
|
if (gpgme_subkey->secret == 1) {
|
||||||
PHPC_HASH_CSTR_ADD_PTR(PHPC_THIS->decryptkeys, gpgme_subkey->keyid, passphrase, passphrase_len + 1);
|
PHPC_HASH_CSTR_ADD_PTR(
|
||||||
|
PHPC_THIS->decryptkeys, gpgme_subkey->keyid,
|
||||||
|
passphrase, passphrase_len + 1);
|
||||||
}
|
}
|
||||||
gpgme_subkey = gpgme_subkey->next;
|
gpgme_subkey = gpgme_subkey->next;
|
||||||
}
|
}
|
||||||
|
@ -1005,21 +1007,24 @@ PHP_FUNCTION(gnupg_addencryptkey)
|
||||||
GNUPG_GETOBJ();
|
GNUPG_GETOBJ();
|
||||||
|
|
||||||
if (this) {
|
if (this) {
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key_id, &key_id_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
|
||||||
|
&key_id, &key_id_len) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &res, &key_id, &key_id_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs",
|
||||||
|
&res, &key_id, &key_id_len) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUPG_RES_FETCH();
|
GNUPG_RES_FETCH();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((PHPC_THIS->err = gpgme_get_key(PHPC_THIS->ctx, key_id, &gpgme_key, 0)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_get_key(PHPC_THIS->ctx, key_id, &gpgme_key, 0))) {
|
||||||
GNUPG_ERR("get_key failed");
|
GNUPG_ERR("get_key failed");
|
||||||
return;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
PHPC_THIS->encryptkeys = erealloc(PHPC_THIS->encryptkeys, sizeof(PHPC_THIS->encryptkeys) * (PHPC_THIS->encrypt_size + 2));
|
PHPC_THIS->encryptkeys = erealloc(PHPC_THIS->encryptkeys,
|
||||||
|
sizeof(PHPC_THIS->encryptkeys) * (PHPC_THIS->encrypt_size + 2));
|
||||||
PHPC_THIS->encryptkeys[PHPC_THIS->encrypt_size] = gpgme_key;
|
PHPC_THIS->encryptkeys[PHPC_THIS->encrypt_size] = gpgme_key;
|
||||||
PHPC_THIS->encrypt_size++;
|
PHPC_THIS->encrypt_size++;
|
||||||
PHPC_THIS->encryptkeys[PHPC_THIS->encrypt_size] = NULL;
|
PHPC_THIS->encryptkeys[PHPC_THIS->encrypt_size] = NULL;
|
||||||
|
|
Loading…
Reference in a new issue