File tree 6 files changed +45
-8
lines changed
6 files changed +45
-8
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 2
2
Test gzcompress() function : basic functionality
3
3
--EXTENSIONS--
4
4
zlib
5
+ --SKIPIF--
6
+ <?php if (getenv ('TRAVIS ' )) die ('skip Currently fails on Travis ' ); ?>
5
7
--FILE--
6
8
<?php
7
9
/*
Original file line number Diff line number Diff line change 2
2
Test gzdeflate() function : basic functionality
3
3
--EXTENSIONS--
4
4
zlib
5
+ --SKIPIF--
6
+ <?php if (getenv ('TRAVIS ' )) die ('skip Currently fails on Travis ' ); ?>
5
7
--FILE--
6
8
<?php
7
9
/*
Original file line number Diff line number Diff line change 2
2
Test gzencode() function : basic functionality
3
3
--EXTENSIONS--
4
4
zlib
5
+ --SKIPIF--
6
+ <?php if (getenv ('TRAVIS ' )) die ('skip Currently fails on Travis ' ); ?>
5
7
--FILE--
6
8
<?php
7
9
/*
Original file line number Diff line number Diff line change @@ -207,17 +207,21 @@ struct _php_stream {
207
207
void * wrapperthis ; /* convenience pointer for an instance of a wrapper */
208
208
zval wrapperdata ; /* fgetwrapperdata retrieves this */
209
209
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 */
214
214
215
215
/* so we know how to clean it up correctly. This should be set to
216
216
* PHP_STREAM_FCLOSE_XXX as appropriate */
217
- uint8_t fclose_stdiocast :2 ;
217
+ uint16_t fclose_stdiocast :2 ;
218
+
218
219
219
220
/* 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 ;
221
225
222
226
char mode [16 ]; /* "rwb" etc. ala stdio */
223
227
Original file line number Diff line number Diff line change @@ -1322,8 +1322,13 @@ PHPAPI zend_off_t _php_stream_tell(php_stream *stream)
1322
1322
PHPAPI int _php_stream_seek (php_stream * stream , zend_off_t offset , int whence )
1323
1323
{
1324
1324
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
+ }
1327
1332
}
1328
1333
1329
1334
/* handle the case where we are in the buffer */
You can’t perform that action at this time.
0 commit comments