Fix CS in gnupg_verify

This commit is contained in:
Jakub Zelenka 2016-10-25 20:35:34 +01:00
parent 91f392fa9f
commit 0e92c34de0

21
gnupg.c
View file

@ -1332,49 +1332,54 @@ PHP_FUNCTION(gnupg_verify)
GNUPG_GETOBJ(); GNUPG_GETOBJ();
if (this) { if (this) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &signed_text, &signature, &plain_text) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z",
&signed_text, &signature, &plain_text) == FAILURE) {
return; return;
} }
} else { } else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz|z", &res, &signed_text, &signature, &plain_text) == FAILURE) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz|z",
&res, &signed_text, &signature, &plain_text) == FAILURE) {
return; return;
} }
GNUPG_RES_FETCH(); GNUPG_RES_FETCH();
} }
if (Z_TYPE_P(signature) == IS_STRING) { /* detached signature */ if (Z_TYPE_P(signature) == IS_STRING) { /* detached signature */
/* setup signature-databuffer for gpgme */ /* setup signature-databuffer for gpgme */
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_sig, Z_STRVAL_P(signature), Z_STRLEN_P(signature), 0)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
&gpgme_sig, Z_STRVAL_P(signature), Z_STRLEN_P(signature), 0))) {
GNUPG_ERR("could not create signature-databuffer"); GNUPG_ERR("could not create signature-databuffer");
return; return;
} }
/* and the text */ /* and the text */
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_text, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
&gpgme_text, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0))) {
GNUPG_ERR("could not create text-databuffer"); GNUPG_ERR("could not create text-databuffer");
gpgme_data_release(gpgme_sig); gpgme_data_release(gpgme_sig);
gpgme_data_release(gpgme_text); gpgme_data_release(gpgme_text);
return; return;
} }
/* now verify sig + text */ /* now verify sig + text */
if ((PHPC_THIS->err = gpgme_op_verify (PHPC_THIS->ctx, gpgme_sig, gpgme_text, NULL)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, gpgme_text, NULL))) {
GNUPG_ERR("verify failed"); GNUPG_ERR("verify failed");
gpgme_data_release(gpgme_sig); gpgme_data_release(gpgme_sig);
gpgme_data_release(gpgme_text); gpgme_data_release(gpgme_text);
return; return;
} }
} else { /* clearsign or normal signature */ } else { /* clearsign or normal signature */
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_sig, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
&gpgme_sig, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0))) {
GNUPG_ERR("could not create signature-databuffer"); GNUPG_ERR("could not create signature-databuffer");
return; return;
} }
/* set a NULL databuffer for gpgme */ /* set a NULL databuffer for gpgme */
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_text, NULL, 0, 0)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(&gpgme_text, NULL, 0, 0))) {
GNUPG_ERR("could not create text-databuffer"); GNUPG_ERR("could not create text-databuffer");
gpgme_data_release(gpgme_sig); gpgme_data_release(gpgme_sig);
gpgme_data_release(gpgme_text); gpgme_data_release(gpgme_text);
return; return;
} }
/* and verify the 'signature' */ /* and verify the 'signature' */
if ((PHPC_THIS->err = gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, NULL, gpgme_text)) != GPG_ERR_NO_ERROR) { if (!PHP_GNUPG_DO(gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, NULL, gpgme_text))) {
GNUPG_ERR("verify failed"); GNUPG_ERR("verify failed");
gpgme_data_release(gpgme_sig); gpgme_data_release(gpgme_sig);
gpgme_data_release(gpgme_text); gpgme_data_release(gpgme_text);