Skip to content

Commit 97eff7e

Browse files
committed
Fix bug #72241: get_icu_value_internal out-of-bounds read
1 parent 0da8b8b commit 97eff7e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Diff for: ext/intl/locale/locale_methods.c

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ static char* get_icu_value_internal( const char* loc_name , char* tag_name, int*
326326
if( U_FAILURE( status ) ) {
327327
if( status == U_BUFFER_OVERFLOW_ERROR ) {
328328
status = U_ZERO_ERROR;
329+
buflen++; /* add space for \0 */
329330
continue;
330331
}
331332

Diff for: ext/intl/tests/bug72241.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #72241: get_icu_value_internal out-of-bounds read
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
$var1=str_repeat("A", 1000);
8+
$out = locale_get_primary_language($var1);
9+
echo strlen($out) . PHP_EOL;
10+
echo unpack('H*', $out)[1] . PHP_EOL;
11+
--EXPECT--
12+
1000
13+
61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161
14+

0 commit comments

Comments
 (0)