1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 22:22:18 +02:00
Files
archived-php-src/ext/mbstring/tests/bug79149.phpt
Nikita Popov 5589bf4d4a Fix length inconsistency in mb_convert_encoding
Don't mix strlen() and ZSTR_LEN(). If the encoding contains a
NULL byte, this will overflow the buffer.

NULL bytes will still make this behave oddly because the consuming
code will cut off the string there, but let's address that in master...
2020-01-29 12:19:28 +01:00

26 lines
805 B
PHP

--TEST--
Bug #79149 (SEGV in mb_convert_encoding with non-string encodings)
--SKIPIF--
<?php
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
?>
--FILE--
<?php
var_dump(mb_convert_encoding("", "UTF-8", [0]));
var_dump(mb_convert_encoding('foo', 'UTF-8', array(['bar'], ['baz'])));
var_dump(mb_convert_encoding('foo', 'UTF-8', array("foo\0bar")));
?>
--EXPECTF--
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
string(0) ""
Notice: Array to string conversion in %s on line %d
Notice: Array to string conversion in %s on line %d
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
string(3) "foo"
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
string(3) "foo"