com php-src: fix datatype mismatches, add stronger error checks: ext/openssl/openssl.c

From: Date: Fri, 30 Jan 2015 10:10:11 +0000
Subject: com php-src: fix datatype mismatches, add stronger error checks: ext/openssl/openssl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84455@lists.php.net to get a copy of this message
Commit: f6330f9912f7edb0a02d0431a621fc513006b137 Author: Anatol Belski <ab@php.net> Fri, 30 Jan 2015 11:10:11 +0100 Parents: 55936775d2722b5fe6ea1355b68a8a7fd0e4b1e5 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f6330f9912f7edb0a02d0431a621fc513006b137 Log: fix datatype mismatches, add stronger error checks Changed paths: M ext/openssl/openssl.c Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 460ea45..169b4b8 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1611,6 +1611,7 @@ PHP_FUNCTION(openssl_spki_export) { size_t spkstr_len; char *spkstr = NULL, * spkstr_cleaned = NULL, * s = NULL; + int spkstr_cleaned_len; EVP_PKEY *pkey = NULL; NETSCAPE_SPKI *spki = NULL; @@ -1627,9 +1628,14 @@ PHP_FUNCTION(openssl_spki_export) } spkstr_cleaned = emalloc(spkstr_len + 1); - openssl_spki_cleanup(spkstr, spkstr_cleaned); + spkstr_cleaned_len = (int)(spkstr_len - openssl_spki_cleanup(spkstr, spkstr_cleaned)); - spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, strlen(spkstr_cleaned)); + if (spkstr_cleaned_len == 0) { + php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); + goto cleanup; + } + + spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, spkstr_cleaned_len); if (spki == NULL) { php_error_docref(NULL, E_WARNING, "Unable to decode supplied SPKAC"); goto cleanup; @@ -1671,6 +1677,7 @@ PHP_FUNCTION(openssl_spki_export_challenge) { size_t spkstr_len; char *spkstr = NULL, * spkstr_cleaned = NULL; + int spkstr_cleaned_len; NETSCAPE_SPKI *spki = NULL; @@ -1685,9 +1692,14 @@ PHP_FUNCTION(openssl_spki_export_challenge) } spkstr_cleaned = emalloc(spkstr_len + 1); - openssl_spki_cleanup(spkstr, spkstr_cleaned); + spkstr_cleaned_len = (int)(spkstr_len - openssl_spki_cleanup(spkstr, spkstr_cleaned)); - spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, strlen(spkstr_cleaned)); + if (spkstr_cleaned_len == 0) { + php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); + goto cleanup; + } + + spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, spkstr_cleaned_len); if (spki == NULL) { php_error_docref(NULL, E_WARNING, "Unable to decode SPKAC"); goto cleanup;

« previous php.cvs (#84455) next »