Skip to content

Commit

Permalink
Fixed bug #74385 Locale::parseLocale() broken with some arguments
Browse files Browse the repository at this point in the history
Rely on the ICU's defined values for the max locale id length.
  • Loading branch information
weltling committed May 3, 2018
1 parent 5b3e1de commit f59b201
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ext/intl/intl_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
}

Expand Down

0 comments on commit f59b201

Please sign in to comment.