Skip to content

Commit 7abe3fe

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents 59dcb00 + 4da89d8 commit 7abe3fe

File tree

7 files changed

+52
-11
lines changed

7 files changed

+52
-11
lines changed

NEWS

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ PHP NEWS
1111
- PHPDBG:
1212
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)
1313

14+
- SQLite3:
15+
. Fixed bug GH-12633 (sqlite3_defensive.phpt fails with sqlite 3.44.0).
16+
(SakiTakamachi)
17+
1418
- Standard:
1519
. Fix memory leak in syslog device handling. (danog)
1620
. Fixed bug GH-12621 (browscap segmentation fault when configured in the
1721
vhost). (nielsdos)
1822
. Fixed bug GH-12655 (proc_open() does not take into account references
1923
in the descriptor array). (nielsdos)
2024

21-
- SQLite3:
22-
. Fixed bug GH-12633 (sqlite3_defensive.phpt fails with sqlite 3.44.0).
23-
(SakiTakamachi)
25+
- Streams:
26+
. Fixed bug #79945 (Stream wrappers in imagecreatefrompng causes segfault).
27+
(Jakub Zelenka)
2428

2529
- Zip:
2630
. Fixed bug GH-12661 (Inconsistency in ZipArchive::addGlob remove_path Option

ext/gd/tests/bug79945.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #79945 (using php wrappers in imagecreatefrompng causes segmentation fault)
3+
--EXTENSIONS--
4+
gd
5+
--SKIPIF--
6+
<?php
7+
set_error_handler(function($errno, $errstr) {
8+
if (str_contains($errstr, 'Cannot cast a filtered stream on this system')) {
9+
die('skip: fopencookie not support on this system');
10+
}
11+
});
12+
imagecreatefrompng('php://filter/read=convert.base64-encode/resource=' . __DIR__ . '/test.png');
13+
restore_error_handler();
14+
?>
15+
--FILE--
16+
<?php
17+
imagecreatefrompng('php://filter/read=convert.base64-encode/resource=' . __DIR__ . '/test.png');
18+
?>
19+
--CLEAN--
20+
--EXPECTF--
21+
22+
Warning: imagecreatefrompng(): "php://filter/read=convert.base64-encode/resource=%s" is not a valid PNG file in %s on line %d

ext/zlib/tests/gzcompress_basic1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Test gzcompress() function : basic functionality
33
--EXTENSIONS--
44
zlib
5+
--SKIPIF--
6+
<?php if (getenv('TRAVIS')) die('skip Currently fails on Travis'); ?>
57
--FILE--
68
<?php
79
/*

ext/zlib/tests/gzdeflate_basic1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Test gzdeflate() function : basic functionality
33
--EXTENSIONS--
44
zlib
5+
--SKIPIF--
6+
<?php if (getenv('TRAVIS')) die('skip Currently fails on Travis'); ?>
57
--FILE--
68
<?php
79
/*

ext/zlib/tests/gzencode_basic1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Test gzencode() function : basic functionality
33
--EXTENSIONS--
44
zlib
5+
--SKIPIF--
6+
<?php if (getenv('TRAVIS')) die('skip Currently fails on Travis'); ?>
57
--FILE--
68
<?php
79
/*

main/php_streams.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,21 @@ struct _php_stream {
207207
void *wrapperthis; /* convenience pointer for an instance of a wrapper */
208208
zval wrapperdata; /* fgetwrapperdata retrieves this */
209209

210-
uint8_t is_persistent:1;
211-
uint8_t in_free:2; /* to prevent recursion during free */
212-
uint8_t eof:1;
213-
uint8_t __exposed:1; /* non-zero if exposed as a zval somewhere */
210+
uint16_t is_persistent:1;
211+
uint16_t in_free:2; /* to prevent recursion during free */
212+
uint16_t eof:1;
213+
uint16_t __exposed:1; /* non-zero if exposed as a zval somewhere */
214214

215215
/* so we know how to clean it up correctly. This should be set to
216216
* PHP_STREAM_FCLOSE_XXX as appropriate */
217-
uint8_t fclose_stdiocast:2;
217+
uint16_t fclose_stdiocast:2;
218+
218219

219220
/* flag to mark whether the stream has buffered data */
220-
uint8_t has_buffered_data:1;
221+
uint16_t has_buffered_data:1;
222+
223+
/* whether stdio cast flushing is in progress */
224+
uint16_t fclose_stdiocast_flush_in_progress:1;
221225

222226
char mode[16]; /* "rwb" etc. ala stdio */
223227

main/streams/streams.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,13 @@ PHPAPI zend_off_t _php_stream_tell(php_stream *stream)
13221322
PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
13231323
{
13241324
if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
1325-
/* flush to commit data written to the fopencookie FILE* */
1326-
fflush(stream->stdiocast);
1325+
/* flush can call seek internally so we need to prevent an infinite loop */
1326+
if (!stream->fclose_stdiocast_flush_in_progress) {
1327+
stream->fclose_stdiocast_flush_in_progress = 1;
1328+
/* flush to commit data written to the fopencookie FILE* */
1329+
fflush(stream->stdiocast);
1330+
stream->fclose_stdiocast_flush_in_progress = 0;
1331+
}
13271332
}
13281333

13291334
/* handle the case where we are in the buffer */

0 commit comments

Comments
 (0)