From: Anatol Belski Date: Thu, 3 May 2018 14:34:33 +0000 (+0200) Subject: Fixed bug #74385 Locale::parseLocale() broken with some arguments X-Git-Tag: php-7.1.18RC1~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f59b201f199155a944a9411cc474a593d0f481a2;p=php Fixed bug #74385 Locale::parseLocale() broken with some arguments Rely on the ICU's defined values for the max locale id length. --- 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; \ }