Skip to content

Commit 1e92d47

Browse files
committed
Do not allow zend.script_encoding to be set to 'pass'
When investigating another bug reported by GitHub user 'tstangner', I discovered that PHP segfaults when the INI parameter zend.script_encoding is set to "pass". This bug dates back to December 2022 (caused by yours truly in 9538646). If any PHP users in the wild were actually setting zend.script_encoding to "pass" (which would be an utterly useless thing to do), I expect that someone would have filed a bug report by now. The absence of such bug reports is evidence that nobody is doing this. Hence, it seems that the best fix is simply to disallow "pass" as a choice for zend.script_encoding. The internal function 'php_mb_zend_encoding_list_parser' which I am modifying to accomplish this has no other in-tree callers, aside from the 'exif' extension. Further, exif only calls the function with a few hard-coded values, and none of them are the string "pass", so this change will not have any impact on exif.
1 parent cb97e7d commit 1e92d47

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Don't segfault when zend.script_encoding=pass
3+
--EXTENSIONS--
4+
mbstring
5+
--INI--
6+
zend.multibyte=1
7+
zend.script_encoding=pass
8+
internal_encoding=UTF-8
9+
--FILE--
10+
<?php
11+
print "Done!\n";
12+
?>
13+
--EXPECT--
14+
Warning: PHP Startup: INI setting contains invalid encoding "pass" in Unknown on line 0
15+
Done!

ext/mbstring/mbstring.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static zend_result php_mb_zend_encoding_list_parser(const char *encoding_list, s
474474
return php_mb_parse_encoding_list(
475475
encoding_list, encoding_list_len,
476476
(const mbfl_encoding ***)return_list, return_size,
477-
persistent, /* arg_num */ 0, /* allow_pass_encoding */ 1);
477+
persistent, /* arg_num */ 0, /* allow_pass_encoding */ 0);
478478
}
479479

480480
static const zend_encoding *php_mb_zend_internal_encoding_getter(void)

0 commit comments

Comments
 (0)