Bug #77104 [NEW]: exif_read_data will fail with EOF on non-file streams containing large tags
| From: | magicaltux at gmail dot com | Date: | Sun, 04 Nov 2018 02:12:03 +0000 |
| Subject: | Bug #77104 [NEW]: exif_read_data will fail with EOF on non-file streams containing large tags | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217813@lists.php.net to get a copy of this message | ||
From: magicaltux at gmail dot com
Operating system: Linux
PHP version: 7.2.11
Package: EXIF related
Bug Type: Bug
Bug description:exif_read_data will fail with EOF on non-file streams containing large tags
Description:
------------
exif_read_data() accepts a mixed $stream parameter to read from, however
the source code makes use of php_stream_read() and will return a
"Unexpected end of file reached" error if not enough bytes are
returned.
However php_stream_read() when used on something else than a regular
file (a seekable stream wrapper in my case) only perform a single call
for 8192 bytes maximum, leaving ext/exif return a EOF error.
Two places in the code:
https://github.com/php/php-src/blob/master/ext/exif/exif.c#L3300
https://github.com/php/php-src/blob/master/ext/exif/exif.c#L3793
ext/exif should, in case php_stream_read() was able to read some but not
all bytes, continue reading until nothing is read at all or requested
data is read.
Test script:
---------------
(writing a specific test for this would require a lot of work as it'd
need a stream wrapper/etc)
Actual result:
--------------
Warning: exif_read_data(): Unexpected end of file reached in test.php on
line 9
Warning: exif_read_data(): Invalid TIFF file in test.php on line 9
--
Edit bug report at https://bugs.php.net/bug.php?id=77104&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77104&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77104&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77104&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77104&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77104&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77104&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77104&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77104&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77104&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77104&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77104&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77104&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77104&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77104&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77104&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77104&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77104&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77104&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77104&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77104&r=mysqlcfg