File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ GHSA-wm6j-2649-pv75: Null pointer dereference in php_mb_check_encoding() via mb_ereg_search_init()
3+ --CREDITS--
4+ vi3tL0u1s
5+ --EXTENSIONS--
6+ mbstring
7+ --SKIPIF--
8+ <?php
9+ if (!function_exists ('mb_regex_encoding ' )) die ('skip No mbregex support ' );
10+ ?>
11+ --FILE--
12+ <?php
13+ // iso-8859-11 is supported by Oniguruma but not by mbfl
14+ mb_regex_encoding ('iso-8859-11 ' );
15+ mb_ereg_search_init ('x ' );
16+ ?>
17+ --EXPECTF--
18+ Fatal error: Uncaught ValueError: mb_regex_encoding(): Argument #1 ($encoding) must be a valid encoding, "iso-8859-11" given in %s:%d
19+ Stack trace:
20+ #0 %s(%d): mb_regex_encoding('iso-8859-11')
21+ #1 {main}
22+ thrown in %s on line %d
Original file line number Diff line number Diff line change @@ -409,8 +409,13 @@ int php_mb_regex_set_mbctype(const char *encname)
409409 if (mbctype == ONIG_ENCODING_UNDEF ) {
410410 return FAILURE ;
411411 }
412+ const mbfl_encoding * mbfl_enc = mbfl_name2encoding (encname );
413+ if (mbfl_enc == NULL ) {
414+ /* Encoding supported by Oniguruma but not by mbfl */
415+ return FAILURE ;
416+ }
412417 MBREX (current_mbctype ) = mbctype ;
413- MBREX (current_mbctype_mbfl_encoding ) = mbfl_name2encoding ( encname ) ;
418+ MBREX (current_mbctype_mbfl_encoding ) = mbfl_enc ;
414419 return SUCCESS ;
415420}
416421/* }}} */
You can’t perform that action at this time.
0 commit comments