diff options
author | Stanislav Malyshev <stas@php.net> | 2013-12-10 11:35:26 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-12-10 11:35:26 -0800 |
commit | 41cd53329871cb99799cd9a8f76151312be2e960 (patch) | |
tree | 9240548c199fee937652673564f61b5b8505e78d /ext/openssl/openssl.c | |
parent | bc8f7761f37d0cadfe72725c7b5e37d698b4db5d (diff) | |
parent | b1b23abc868e25f9ee083e8837c37867516ee380 (diff) | |
download | php-git-41cd53329871cb99799cd9a8f76151312be2e960.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
5.3.29-dev
Fix CVE-2013-6420 - memory corruption in openssl_x509_parse
Diffstat (limited to 'ext/openssl/openssl.c')
-rw-r--r-- | ext/openssl/openssl.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 59a58b1c00..90ef9b035f 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -657,18 +657,28 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */ char * thestr; long gmadjust = 0; - if (timestr->length < 13) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "extension author too lazy to parse %s correctly", timestr->data); + if (ASN1_STRING_type(timestr) != V_ASN1_UTCTIME) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "illegal ASN1 data type for timestamp"); return (time_t)-1; } - strbuf = estrdup((char *)timestr->data); + if (ASN1_STRING_length(timestr) != strlen(ASN1_STRING_data(timestr))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "illegal length in timestamp"); + return (time_t)-1; + } + + if (ASN1_STRING_length(timestr) < 13) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to parse time string %s correctly", timestr->data); + return (time_t)-1; + } + + strbuf = estrdup((char *)ASN1_STRING_data(timestr)); memset(&thetime, 0, sizeof(thetime)); /* we work backwards so that we can use atoi more easily */ - thestr = strbuf + timestr->length - 3; + thestr = strbuf + ASN1_STRING_length(timestr) - 3; thetime.tm_sec = atoi(thestr); *thestr = '\0'; |