Skip to content

Commit

Permalink
Merge branch 'PHP-8.2'
Browse files Browse the repository at this point in the history
* PHP-8.2:
  Add missing check on EVP_VerifyUpdate() in phar util
  • Loading branch information
nielsdos committed Jul 9, 2023
2 parents a7f7022 + 3ee2ade commit 15bdc85
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/phar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,9 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type,
php_stream_seek(fp, 0, SEEK_SET);

while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
EVP_VerifyUpdate (md_ctx, buf, len);
if (UNEXPECTED(EVP_VerifyUpdate (md_ctx, buf, len) == 0)) {
goto failure;
}
read_len -= (zend_off_t)len;

if (read_len < read_size) {
Expand All @@ -1614,6 +1616,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type,
}

if (EVP_VerifyFinal(md_ctx, (unsigned char *)sig, sig_len, key) != 1) {
failure:
/* 1: signature verified, 0: signature does not match, -1: failed signature operation */
EVP_PKEY_free(key);
EVP_MD_CTX_destroy(md_ctx);
Expand Down

0 comments on commit 15bdc85

Please sign in to comment.