imagecreatefrom... crashes with user streams
| Bug #65060 | imagecreatefrom... crashes with user streams | ||||
|---|---|---|---|---|---|
| Submitted: | 2013-06-19 08:08 UTC | Modified: | 2013-06-21 15:23 UTC | ||
| From: | thekid@php.net | Assigned: | thekid (profile) | ||
| Status: | Closed | Package: | GD related | ||
| PHP Version: | 5.5.0RC3 | OS: | gentoo | ||
| Private report: | No | CVE-ID: | None | ||
[2013-06-19 08:08 UTC] 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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2013-06-19 08:35 UTC] pajoye@php.net
[2013-06-19 08:38 UTC] pajoye@php.net
-Operating System: Linux +Operating System: gentoo
[2013-06-19 08:38 UTC] pajoye@php.net
[2013-06-19 09:00 UTC] thekid@php.net
[2013-06-21 05:31 UTC] pajoye@php.net
[2013-06-21 05:37 UTC] pajoye@php.net
[2013-06-21 05:38 UTC] pajoye@php.net
[2013-06-21 12:11 UTC] remi@php.net
-Status: Open +Status: Closed
[2013-06-21 15:23 UTC] thekid@php.net
-Assigned To: +Assigned To: thekid
[2013-06-23 22:25 UTC] stas@php.net