Skip to content

Commit 929d847

Browse files
committed
Fix #81693: mb_check_encoding(7bit) segfaults
`php_mb_check_encoding()` now uses conversion to `mbfl_encoding_wchar`. Since `mbfl_encoding_7bit` has no `input_filter`, no filter can be found. Since we don't actually need to convert to wchar, we encode to 8bit. Closes GH-7712.
1 parent 7a6fb97 commit 929d847

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.2
44

5+
- MBString:
6+
. Fixed bug #81693 (mb_check_encoding(7bit) segfaults). (cmb)
7+
58
- Reflection:
69
. Fixed bug #81681 (ReflectionEnum throwing exceptions). (cmb)
710

ext/mbstring/libmbfl/mbfl/mbfl_convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ const struct mbfl_convert_vtbl* mbfl_convert_filter_get_vtbl(const mbfl_encoding
307307
from = &mbfl_encoding_8bit;
308308
} else if (from->no_encoding == mbfl_no_encoding_base64 ||
309309
from->no_encoding == mbfl_no_encoding_qprint ||
310-
from->no_encoding == mbfl_no_encoding_uuencode) {
310+
from->no_encoding == mbfl_no_encoding_uuencode ||
311+
from->no_encoding == mbfl_no_encoding_7bit) {
311312
to = &mbfl_encoding_8bit;
312313
}
313314

ext/mbstring/tests/bug81693.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #81693 (mb_check_encoding(7bit) segfaults)
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
var_dump(mb_check_encoding('Hello world', '7bit'));
8+
?>
9+
--EXPECT--
10+
bool(true)

0 commit comments

Comments
 (0)