Bug #65060 [Fbk]: imagecreatefrom... crashes with user streams
| From: | pajoye@php.net | Date: | Wed, 19 Jun 2013 08:38:33 +0000 |
| Subject: | Bug #65060 [Fbk]: imagecreatefrom... crashes with user streams | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179621@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65060&edit=1
ID: 65060
Updated by: pajoye@php.net
Reported by: thekid@php.net
Summary: imagecreatefrom... crashes with user streams
Status: Feedback
Type: Bug
Package: GD related
-Operating System: Linux
+Operating System: gentoo
PHP Version: 5.5.0RC3
Block user comment: N
Private report: N
New Comment:
should have read more carefully :)
So only the system or bundled gd question remains :)
Previous Comments:
------------------------------------------------------------------------
[2013-06-19 08:35:49] pajoye@php.net
g:\php-sdk\php-master\vc11\x86\php-src-clean>g:\temp\5.5.0rc3-nts\php -d
extension_dir=g:\temp\5.5.0rc3-nts\ext\ -d extension=php_gd2.dll 65060.php
Warning: imagecreatefromgif(): userstream::stream_cast is not implemented! in
G:\php-sdk\php-master\vc11\x86\php-src-clean\65060.php on line 38
resource(7) of type (gd)
do you use system's gd or bundled one? Can you try with the bundled one please
(if system's is used).
Which Distro do you use?
------------------------------------------------------------------------
[2013-06-19 08:08:43] thekid@php.net
Description:
------------
When loading images via any of the imagecreatefrom...() functions and the argument given to them
resolves to a userstream, a segmentation fault occurs on Linux systems (Travis CI's Linux
image, 3.2.9-gentoo). With PHP 5.4, the same code works as expected. On Windows, the same code works
as expected.
See https://github.com/xp-framework/xp-framework/issues/310
Test script:
---------------
<?php
class userstream {
public static $bytes= array();
public function stream_open($path, $mode, $options, $opened_path) {
sscanf($path, 'iostrr://%s', $file);
if (!isset(self::$bytes[$file])) return false;
$this->buffer= self::$bytes[$file];
$this->avail= strlen($this->buffer);
$this->length= strlen($this->buffer);
return true;
}
public function stream_read($count) {
$chunk= substr($this->buffer, 0, min($this->avail, $count));
$this->buffer= substr($this->buffer, strlen($chunk));
$this->avail-= strlen($chunk);
return $chunk;
}
public function stream_stat() {
return array('size' => $this->length);
}
public function stream_eof() {
return $this->avail <= 0;
}
public function stream_close() {
$this->avail= -1;
}
}
userstream::$bytes['test.gif']=
base64_decode('R0lGODdhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=');
stream_wrapper_register('iostrr', 'userstream');
var_dump(imagecreatefromgif('iostrr://test.gif'));
Expected result:
----------------
resource(6) of type (gd)
Actual result:
--------------
Segmentation fault
Program received signal SIGSEGV, Segmentation fault.
0x00005555558b2d77 in _php_stream_seek (stream=0x7fffefc6d6b0, offset=-1, whence=1)
at /home/friebe/php/php-src/main/streams/streams.c:1273
1273 fflush(stream->stdiocast);
(gdb) bt
#0 0x00005555558b2d77 in _php_stream_seek (stream=0x7fffefc6d6b0, offset=-1, whence=1)
at /home/friebe/php/php-src/main/streams/streams.c:1273
#1 0x00005555558b4fa0 in stream_cookie_seeker (cookie=<optimized out>,
position=0x7fffff7ff458,
whence=<optimized out>) at /home/friebe/php/php-src/main/streams/cast.c:117
#2 0x00007ffff6571fb6 in ?? () from /lib64/libc.so.6
#3 0x00007ffff657d1e5 in _IO_file_sync () from /lib64/libc.so.6
#4 0x00007ffff65718e1 in fflush () from /lib64/libc.so.6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65060&edit=1