summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-05-03 16:34:33 +0200
committerAnatol Belski <ab@php.net>2018-05-03 16:34:33 +0200
commitf59b201f199155a944a9411cc474a593d0f481a2 (patch)
tree18ff116e5fd456bf9973106b064463006b7b11a0
parent5b3e1ded356dc877aa246d28e71e69286b8829b5 (diff)
downloadphp-git-f59b201f199155a944a9411cc474a593d0f481a2.tar.gz
Fixed bug #74385 Locale::parseLocale() broken with some arguments
Rely on the ICU's defined values for the max locale id length.
-rw-r--r--ext/intl/intl_data.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h
index 74b7092fbb..898a174a22 100644
--- a/ext/intl/intl_data.h
+++ b/ext/intl/intl_data.h
@@ -103,19 +103,23 @@ typedef struct _intl_data {
RETVAL_NEW_STR(u8str); \
}
-#define INTL_MAX_LOCALE_LEN 80
+#define INTL_MAX_LOCALE_LEN (ULOC_FULLNAME_CAPACITY-1)
#define INTL_CHECK_LOCALE_LEN(locale_len) \
if((locale_len) > INTL_MAX_LOCALE_LEN) { \
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, \
- "Locale string too long, should be no longer than 80 characters", 0 ); \
+ char *_msg; \
+ spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
+ efree(_msg); \
RETURN_NULL(); \
}
#define INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len) \
if((locale_len) > INTL_MAX_LOCALE_LEN) { \
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, \
- "Locale string too long, should be no longer than 80 characters", 0 ); \
+ char *_msg; \
+ spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
+ efree(_msg); \
return FAILURE; \
}