summaryrefslogtreecommitdiff
path: root/ext/openssl/openssl.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2013-12-10 11:33:40 -0800
committerStanislav Malyshev <stas@php.net>2013-12-10 11:34:35 -0800
commit71daf3229b5707a3553dc7d1971e8a0e77cd9dfb (patch)
tree830d2ef619705dc38abae33f4e63fd9d4b6f115b /ext/openssl/openssl.c
parentc062c18d426e8b1e4d7e4fabb6a5eae331f6e58b (diff)
parent8650bbc8dc6c3b416454f5e38812430edbd438c6 (diff)
downloadphp-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.c18
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';