summaryrefslogtreecommitdiff
path: root/ext/intl/dateformat
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-04-08 12:29:40 +0200
committerAnatol Belski <ab@php.net>2016-04-08 12:31:19 +0200
commit1541a55a4f9207c346a805c2b8d090f16d07f841 (patch)
tree3a4626416ad50b7292f9eba6e0f18dad4e2dc698 /ext/intl/dateformat
parentf7600e17cb8eb6c5dad8709ac1f4c76f0f28f207 (diff)
downloadphp-git-1541a55a4f9207c346a805c2b8d090f16d07f841.tar.gz
Fixed bug #68893 Stackoverflow in datefmt_create
Diffstat (limited to 'ext/intl/dateformat')
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index e90ad74466..8705d4bc0b 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -36,6 +36,13 @@ extern "C" {
#include "dateformat_helpers.h"
#include "zend_exceptions.h"
+#define INTL_UDATE_FMT_OK(i) \
+ (UDAT_FULL == (i) || UDAT_LONG == (i) || \
+ UDAT_MEDIUM == (i) || UDAT_SHORT == (i) || \
+ UDAT_RELATIVE == (i) || UDAT_FULL_RELATIVE == (i) || \
+ UDAT_LONG_RELATIVE == (i) || UDAT_MEDIUM_RELATIVE == (i) || \
+ UDAT_SHORT_RELATIVE == (i) || UDAT_NONE == (i) || \
+ UDAT_PATTERN == (i))
/* {{{ */
static int datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
@@ -72,12 +79,6 @@ static int datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
return FAILURE;
}
- INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
- if (locale_len == 0) {
- locale_str = intl_locale_get_default();
- }
- locale = Locale::createFromName(locale_str);
-
DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
if (DATE_FORMAT_OBJECT(dfo) != NULL) {
@@ -86,6 +87,21 @@ static int datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
return FAILURE;
}
+ if (!INTL_UDATE_FMT_OK(date_type)) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid date format style", 0);
+ return FAILURE;
+ }
+ if (!INTL_UDATE_FMT_OK(time_type)) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style", 0);
+ return FAILURE;
+ }
+
+ INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
+ if (locale_len == 0) {
+ locale_str = intl_locale_get_default();
+ }
+ locale = Locale::createFromName(locale_str);
+
/* process calendar */
if (datefmt_process_calendar_arg(calendar_zv, locale, "datefmt_create",
INTL_DATA_ERROR_P(dfo), calendar, calendar_type,