|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-04-20 14:40 UTC] sergey dot kudich at gmail dot com
Description:
------------
Segmentation Fault if we try getimagesize on zip:// strem
All was ok on php 7.0.16, this is related to phpoffice/phpexcel library
example - just try any file to open, we tried to get image from excel file so putting here example for it
getimagesize('zip:///home/user/workbook.xlsx#xl/media/image1.gif');
If we trying to open this file via fopen
$h = fopen('zip:///home/user/workbook.xlsx#xl/media/image1.gif', 'br');
PHP Warning: fopen(zip:///home/user/workbook.xlsx#xl/media/image1.gif): failed to open stream: operation failed in ...
Same time file_get_contents working well
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
It is the same problem as php 5.6, so I will send a core dump. #0 0x000000000059dafc in php_stream_context_get_option (context=0x0, wrappername=0x7f5c5d3e8ce3 "zip", optionname=0x7f5c5d3e987a "password", optionvalue=0x7fffb7bd4d30) at /usr/src/debug/php-5.6.30/main/streams/streams.c:2227 #1 0x00007f5c5d3e89e6 in php_stream_zip_opener () from /opt/remi/php56/root/usr/lib64/php/modules/zip.so #2 0x000000000059f793 in _php_stream_open_wrapper_ex ( path=0x7f5c6def5258 "zip:///home/quotation_invoice/dev/qi/aaa/quotation_000.xlsx#xl/media/image11.wmf", mode=0x6dce67 "rb", options=24, opened_path=0x0, context=0x0) at /usr/src/debug/php-5.6.30/main/streams/streams.c:2059 #3 0x0000000000544253 in php_getimagesize_from_any (ht=1, return_value=0x7f5c6def4160, return_value_ptr=<value optimized out>, this_ptr=<value optimized out>, return_value_used=<value optimized out>, mode=1) at /usr/src/debug/php-5.6.30/ext/standard/image.c:1408 #4 0x00000000005d9479 in dtrace_execute_internal (execute_data_ptr=<value optimized out>, fci=<value optimized out>, return_value_used=<value optimized out>) at /usr/src/debug/php-5.6.30/Zend/zend_dtrace.c:97 #5 0x00000000006689d5 in zend_do_fcall_common_helper_SPEC (execute_data=<value optimized out>) at /usr/src/debug/php-5.6.30/Zend/zend_vm_execute.h:560 #6 0x00000000006584a8 in execute_ex (execute_data=0x7f5c6dec0238) at /usr/src/debug/php-5.6.30/Zend/zend_vm_execute.h:363 #7 0x00000000005d95ae in dtrace_execute_ex (execute_data=0x7f5c6dec0238) at /usr/src/debug/php-5.6.30/Zend/zend_dtrace.c:73 #8 0x00000000005e8d5c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/debug/php-5.6.30/Zend/zend.c:1341 #9 0x000000000058690a in php_execute_script (primary_file=0x7fffb7bd8730) at /usr/src/debug/php-5.6.30/main/main.c:2613 #10 0x0000000000690b76 in do_cli (argc=2, argv=0x2636c90) at /usr/src/debug/php-5.6.30/sapi/cli/php_cli.c:998 #11 0x0000000000691308 in main (argc=2, argv=0x2636c90) at /usr/src/debug/php-5.6.30/sapi/cli/php_cli.c:1382Hot fix for phpexel. in file PHPExcel/Writer/Excel2007/ContentTypes.php method getImageMimeType changed for me to: private function getImageMimeType($pFile = '') { if (PHPExcel_Shared_File::file_exists($pFile)) { $image = mime_content_type($pFile); $imageType = 0; for ($imageType = 0; $imageType <= 16; $imageType++) { if ($image == image_type_to_mime_type($imageType)) { break; } } return image_type_to_mime_type($imageType); } else { throw new PHPExcel_Writer_Exception("File $pFile does not exist"); } }I used a little bit different hot fix in same file private function _getImageMimeType($pFile = '') { if (PHPExcel_Shared_File::file_exists($pFile)) { $image = getimagesizefromstring(file_get_contents($pFile)); //$image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { throw new PHPExcel_Writer_Exception("File $pFile does not exist"); } }