Skip to content

Commit 44b1619

Browse files
authored
Cleanup pubkey checks in ext/phar (php#11009)
These checks are always true because we bail out early if pubkey is NULL or empty. But by having these checks, it makes the code more confusing because it implies pubkey can be false, while it can in fact not.
1 parent f42992f commit 44b1619

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ext/phar/util.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,10 +1539,8 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type,
15391539
#ifndef PHAR_HAVE_OPENSSL
15401540
tempsig = sig_len;
15411541

1542-
if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0, &sig, &tempsig, sig_type)) {
1543-
if (pubkey) {
1544-
zend_string_release_ex(pubkey, 0);
1545-
}
1542+
if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), &sig, &tempsig, sig_type)) {
1543+
zend_string_release_ex(pubkey, 0);
15461544

15471545
if (error) {
15481546
spprintf(error, 0, "openssl signature could not be verified");
@@ -1551,13 +1549,11 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type,
15511549
return FAILURE;
15521550
}
15531551

1554-
if (pubkey) {
1555-
zend_string_release_ex(pubkey, 0);
1556-
}
1552+
zend_string_release_ex(pubkey, 0);
15571553

15581554
sig_len = tempsig;
15591555
#else
1560-
in = BIO_new_mem_buf(pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0);
1556+
in = BIO_new_mem_buf(ZSTR_VAL(pubkey), ZSTR_LEN(pubkey));
15611557

15621558
if (NULL == in) {
15631559
zend_string_release_ex(pubkey, 0);

0 commit comments

Comments
 (0)