diff options
author | Stanislav Malyshev <stas@php.net> | 2013-12-10 11:33:40 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-12-10 11:34:35 -0800 |
commit | 71daf3229b5707a3553dc7d1971e8a0e77cd9dfb (patch) | |
tree | 830d2ef619705dc38abae33f4e63fd9d4b6f115b /ext/openssl/openssl.c | |
parent | c062c18d426e8b1e4d7e4fabb6a5eae331f6e58b (diff) | |
parent | 8650bbc8dc6c3b416454f5e38812430edbd438c6 (diff) | |
download | php-git-71daf3229b5707a3553dc7d1971e8a0e77cd9dfb.tar.gz |
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
5.3.29-dev
Fix CVE-2013-6420 - memory corruption in openssl_x509_parse
Conflicts:
configure.in
main/php_version.h
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 26792e2428..c73670f3d2 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -645,18 +645,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'; |