Add more locale length checks, due to ICU bugs.
authorStanislav Malyshev <stas@php.net>
Wed, 5 Oct 2016 04:28:40 +0000 (21:28 -0700)
committerAnatol Belski <ab@php.net>
Wed, 12 Oct 2016 11:11:16 +0000 (13:11 +0200)
(cherry picked from commit d3eb58332af433982f1e2ae9095fb087974a95f2)

ext/intl/locale/locale_methods.c

index 32a70d2f7f0b939ba868e675ff39c2a0632b0a02..e2caacf9e9f3c6a745723464a6eabe80172aac0a 100644 (file)
@@ -406,6 +406,8 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
        if(loc_name_len == 0) {
                loc_name = intl_locale_get_default();
        }
+       
+       INTL_CHECK_LOCALE_LEN(strlen(loc_name));
 
        /* Call ICU get */
        tag_value = get_icu_value_internal( loc_name , tag_name , &result ,0);
@@ -1169,6 +1171,7 @@ PHP_FUNCTION(locale_get_all_variants)
                loc_name = intl_locale_get_default();
        }
 
+       INTL_CHECK_LOCALE_LEN(strlen(loc_name));
 
        array_init( return_value );
 
@@ -1277,6 +1280,9 @@ PHP_FUNCTION(locale_filter_matches)
                RETURN_TRUE;
        }
 
+       INTL_CHECK_LOCALE_LEN(strlen(loc_range));
+       INTL_CHECK_LOCALE_LEN(strlen(lang_tag));
+
        if( boolCanonical ){
                /* canonicalize loc_range */
                can_loc_range=get_icu_value_internal( loc_range , LOC_CANONICALIZE_TAG , &result , 0);
@@ -1558,6 +1564,8 @@ PHP_FUNCTION(locale_lookup)
 
        hash_arr = Z_ARRVAL_P(arr);
 
+       INTL_CHECK_LOCALE_LEN(strlen(loc_range));
+
        if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 ) {
                RETURN_EMPTY_STRING();
        }