mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 22:37:10 +00:00
Fix CS in callbacks and init
This commit is contained in:
parent
471a47f41e
commit
4d14a5736c
1 changed files with 39 additions and 11 deletions
50
gnupg.c
50
gnupg.c
|
@ -433,7 +433,8 @@ PHP_MINIT_FUNCTION(gnupg)
|
||||||
PHPC_OBJ_SET_HANDLER_FREE(gnupg);
|
PHPC_OBJ_SET_HANDLER_FREE(gnupg);
|
||||||
|
|
||||||
/* register resource */
|
/* register resource */
|
||||||
le_gnupg = zend_register_list_destructors_ex(gnupg_res_dtor, NULL, "ctx", module_number);
|
le_gnupg = zend_register_list_destructors_ex(
|
||||||
|
gnupg_res_dtor, NULL, "ctx", module_number);
|
||||||
|
|
||||||
if (SUCCESS != gnupg_keylistiterator_init()) {
|
if (SUCCESS != gnupg_keylistiterator_init()) {
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
@ -538,7 +539,8 @@ gpgme_error_t passphrase_cb(
|
||||||
uid[idx] = uid_hint[idx];
|
uid[idx] = uid_hint[idx];
|
||||||
}
|
}
|
||||||
uid[16] = '\0';
|
uid[16] = '\0';
|
||||||
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(PHPC_THIS->signkeys, (char *)uid, passphrase)) {
|
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(
|
||||||
|
PHPC_THIS->signkeys, (char *)uid, passphrase)) {
|
||||||
GNUPG_ERR("no passphrase set");
|
GNUPG_ERR("no passphrase set");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +549,8 @@ gpgme_error_t passphrase_cb(
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, passphrase, strlen(passphrase)) == strlen(passphrase) && write(fd, "\n", 1) == 1) {
|
if (write(fd, passphrase, strlen(passphrase)) == strlen(passphrase)
|
||||||
|
&& write(fd, "\n", 1) == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
GNUPG_ERR("write failed");
|
GNUPG_ERR("write failed");
|
||||||
|
@ -576,7 +579,8 @@ gpgme_error_t passphrase_decrypt_cb (
|
||||||
uid[idx] = uid_hint[idx];
|
uid[idx] = uid_hint[idx];
|
||||||
}
|
}
|
||||||
uid[16] = '\0';
|
uid[16] = '\0';
|
||||||
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(PHPC_THIS->decryptkeys, (char *)uid, passphrase)) {
|
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(
|
||||||
|
PHPC_THIS->decryptkeys, (char *)uid, passphrase)) {
|
||||||
GNUPG_ERR("no passphrase set");
|
GNUPG_ERR("no passphrase set");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +588,8 @@ gpgme_error_t passphrase_decrypt_cb (
|
||||||
GNUPG_ERR("no passphrase set");
|
GNUPG_ERR("no passphrase set");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (write(fd, passphrase, strlen(passphrase)) == strlen(passphrase) && write(fd, "\n", 1) == 1) {
|
if (write(fd, passphrase, strlen(passphrase)) == strlen(passphrase)
|
||||||
|
&& write(fd, "\n", 1) == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
GNUPG_ERR("write failed");
|
GNUPG_ERR("write failed");
|
||||||
|
@ -601,12 +606,35 @@ int gnupg_fetchsignatures(gpgme_signature_t gpgme_signatures, zval *main_arr)
|
||||||
while (gpgme_signatures) {
|
while (gpgme_signatures) {
|
||||||
PHPC_VAL_MAKE(sig_arr);
|
PHPC_VAL_MAKE(sig_arr);
|
||||||
PHPC_ARRAY_INIT(PHPC_VAL_CAST_TO_PZVAL(sig_arr));
|
PHPC_ARRAY_INIT(PHPC_VAL_CAST_TO_PZVAL(sig_arr));
|
||||||
PHPC_ARRAY_ADD_ASSOC_CSTR(PHPC_VAL_CAST_TO_PZVAL(sig_arr), "fingerprint", gpgme_signatures->fpr);
|
PHPC_ARRAY_ADD_ASSOC_CSTR(
|
||||||
PHPC_ARRAY_ADD_ASSOC_LONG(PHPC_VAL_CAST_TO_PZVAL(sig_arr), "validity", gpgme_signatures->validity);
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr),
|
||||||
PHPC_ARRAY_ADD_ASSOC_LONG(PHPC_VAL_CAST_TO_PZVAL(sig_arr), "timestamp", gpgme_signatures->timestamp);
|
"fingerprint",
|
||||||
PHPC_ARRAY_ADD_ASSOC_LONG(PHPC_VAL_CAST_TO_PZVAL(sig_arr), "status", gpgme_signatures->status);
|
gpgme_signatures->fpr
|
||||||
PHPC_ARRAY_ADD_ASSOC_LONG(PHPC_VAL_CAST_TO_PZVAL(sig_arr), "summary", gpgme_signatures->summary);
|
);
|
||||||
PHPC_ARRAY_ADD_NEXT_INDEX_ZVAL(main_arr, PHPC_VAL_CAST_TO_PZVAL(sig_arr));
|
PHPC_ARRAY_ADD_ASSOC_LONG(
|
||||||
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr),
|
||||||
|
"validity",
|
||||||
|
gpgme_signatures->validity
|
||||||
|
);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_LONG(
|
||||||
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr),
|
||||||
|
"timestamp",
|
||||||
|
gpgme_signatures->timestamp
|
||||||
|
);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_LONG(
|
||||||
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr),
|
||||||
|
"status",
|
||||||
|
gpgme_signatures->status
|
||||||
|
);
|
||||||
|
PHPC_ARRAY_ADD_ASSOC_LONG(
|
||||||
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr),
|
||||||
|
"summary",
|
||||||
|
gpgme_signatures->summary
|
||||||
|
);
|
||||||
|
PHPC_ARRAY_ADD_NEXT_INDEX_ZVAL(
|
||||||
|
main_arr,
|
||||||
|
PHPC_VAL_CAST_TO_PZVAL(sig_arr)
|
||||||
|
);
|
||||||
|
|
||||||
gpgme_signatures = gpgme_signatures->next;
|
gpgme_signatures = gpgme_signatures->next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue