Skip to content

Commit 58b0003

Browse files
committed
Merge remote-tracking branch 'security/bug76249' into PHP-5.6
* security/bug76249: Fix test Fix bug #76249 - fail on invalid sequences
2 parents a4c55ee + 8dca5ae commit 58b0003

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ext/iconv/iconv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,6 +2672,9 @@ static int php_iconv_stream_filter_append_bucket(
26722672
tcnt = 0;
26732673
break;
26742674
}
2675+
} else {
2676+
php_error_docref(NULL, E_WARNING, "iconv stream filter (\"%s\"=>\"%s\"): invalid multibyte sequence", self->from_charset, self->to_charset);
2677+
goto out_failure;
26752678
}
26762679
break;
26772680

ext/iconv/tests/bug76249.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #76249 (stream filter convert.iconv leads to infinite loop on invalid sequence)
3+
--SKIPIF--
4+
<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
5+
--FILE--
6+
<?php
7+
$fh = fopen('php://memory', 'rw');
8+
fwrite($fh, "abc");
9+
rewind($fh);
10+
stream_filter_append($fh, 'convert.iconv.ucs-2/utf8//IGNORE', STREAM_FILTER_READ, []);
11+
$a = stream_get_contents($fh);
12+
var_dump(strlen($a));
13+
?>
14+
DONE
15+
--EXPECTF--
16+
Warning: stream_get_contents(): iconv stream filter ("ucs-2"=>"utf8//IGNORE"): invalid multibyte sequence in %sbug76249.php on line %d
17+
int(3)
18+
DONE

0 commit comments

Comments
 (0)