Skip to content

Commit

Permalink
Fix bug #76249 - fail on invalid sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Apr 23, 2018
1 parent cb981e3 commit 06d309f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/iconv/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,9 @@ static int php_iconv_stream_filter_append_bucket(
tcnt = 0;
break;
}
} else {
php_error_docref(NULL, E_WARNING, "iconv stream filter (\"%s\"=>\"%s\"): invalid multibyte sequence", self->from_charset, self->to_charset);
goto out_failure;
}
break;

Expand Down
16 changes: 16 additions & 0 deletions ext/iconv/tests/bug76249.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Bug #76249 (stream filter convert.iconv leads to infinite loop on invalid sequence)
--SKIPIF--
<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
--FILE--
<?php
$fh = fopen('php://memory', 'rw');
fwrite($fh, "abc");
rewind($fh);
stream_filter_append($fh, 'convert.iconv.ucs-2/utf8//IGNORE', STREAM_FILTER_READ, []);
echo stream_get_contents($fh);
?>
DONE
--EXPECTF--
Warning: stream_get_contents(): iconv stream filter ("ucs-2"=>"utf8//IGNORE"): invalid multibyte sequence in %sbug76249.php on line %d
慢DONE

0 comments on commit 06d309f

Please sign in to comment.