Skip to content

Commit c192a34

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-17047: UAF on iconv filter failure
2 parents 3e2cfdf + ddbd396 commit c192a34

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.4.3
44

5+
- Iconv:
6+
. Fixed bug GH-17047 (UAF on iconv filter failure). (nielsdos)
7+
58
- Streams:
69
. Fixed bug GH-17037 (UAF in user filter when adding existing filter name due
710
to incorrect error handling). (nielsdos)

ext/iconv/iconv.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,8 @@ static php_stream_filter_status_t php_iconv_stream_filter_do_filter(
25352535
if (php_iconv_stream_filter_append_bucket(self, stream, filter,
25362536
buckets_out, bucket->buf, bucket->buflen, &consumed,
25372537
php_stream_is_persistent(stream)) != SUCCESS) {
2538-
goto out_failure;
2538+
php_stream_bucket_delref(bucket);
2539+
return PSFS_ERR_FATAL;
25392540
}
25402541

25412542
php_stream_bucket_delref(bucket);
@@ -2545,7 +2546,7 @@ static php_stream_filter_status_t php_iconv_stream_filter_do_filter(
25452546
if (php_iconv_stream_filter_append_bucket(self, stream, filter,
25462547
buckets_out, NULL, 0, &consumed,
25472548
php_stream_is_persistent(stream)) != SUCCESS) {
2548-
goto out_failure;
2549+
return PSFS_ERR_FATAL;
25492550
}
25502551
}
25512552

@@ -2554,12 +2555,6 @@ static php_stream_filter_status_t php_iconv_stream_filter_do_filter(
25542555
}
25552556

25562557
return PSFS_PASS_ON;
2557-
2558-
out_failure:
2559-
if (bucket != NULL) {
2560-
php_stream_bucket_delref(bucket);
2561-
}
2562-
return PSFS_ERR_FATAL;
25632558
}
25642559
/* }}} */
25652560

ext/iconv/tests/gh17047.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-17047 (UAF on iconv filter failure)
3+
--EXTENSIONS--
4+
iconv
5+
--FILE--
6+
<?php
7+
$stream = fopen('php://temp', 'w+');
8+
stream_filter_append($stream, 'convert.iconv.UTF-16BE.UTF-8');
9+
stream_filter_append($stream, 'convert.iconv.UTF-16BE.UTF-16BE');
10+
fputs($stream, 'test');
11+
rewind($stream);
12+
var_dump(stream_get_contents($stream));
13+
fclose($stream);
14+
?>
15+
--EXPECTF--
16+
Warning: stream_get_contents(): iconv stream filter ("UTF-16BE"=>"UTF-16BE"): invalid multibyte sequence in %s on line %d
17+
string(0) ""

0 commit comments

Comments
 (0)