php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75785 Many errors from exif_read_data
Submitted: 2018-01-09 11:04 UTC Modified: 2018-07-19 01:06 UTC
Votes:18
Avg. Score:4.3 ± 0.8
Reproduced:16 of 16 (100.0%)
Same Version:5 (31.2%)
Same OS:3 (18.8%)
From: opajaap at opajaap dot nl Assigned: kalle (profile)
Status: Assigned Package: EXIF related
PHP Version: 7.2.1 OS: unknown
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-01-09 11:04 UTC] opajaap at opajaap dot nl
Description:
------------
In version 7.2.0 i get very many errors from exif_read_data().

To me it looks very unlikely that so many (but not all) of those .jpg files have corrupt exif data.
A few examples:

09.01.2018 11:37:06 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(42996.jpg): corrupt EXIF header: maximum directory nesting level reached in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:28 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43168.jpg): Illegal IFD size: 2 + 0x2000*12 = 0x18002 > 0xA650 in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:35 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43186.jpg): Illegal IFD size: 2 + 0x0A00*12 = 0x7802 > 0x0C00 in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:42 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43279.jpg): Process tag(x0000=UndefinedTa): Illegal format code 0x0000, suppose BYTE in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:42 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43279.jpg): Process tag(x0000=UndefinedTa): Illegal components(0) in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:49 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43303.jpg): Process tag(x0211=YCbCrCoeffi): Illegal components(0) in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:56 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43355.jpg): Illegal IFD size: 2 + 0x4F00*12 = 0x3B402 > 0x1C7C in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:56 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43356.jpg): Illegal IFD size: 2 + 0x4F00*12 = 0x3B402 > 0x1C7C in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:56 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43357.jpg): Illegal IFD size: 2 + 0x4F00*12 = 0x3B402 > 0x1C7C in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options
09.01.2018 11:37:56 2013.opajaap.nl [client 213.10.98.0] PHP Warning:  exif_read_data(43358.jpg): Illegal IFD size: 2 + 0x4F00*12 = 0x3B402 > 0x1C7C in /mnt/web208/b3/15/51893315/htdocs/opajaap/2013/wp-content/plugins/wp-photo-album-plus/wppa-maintenance.php on line 1479, referer: https://2013.opajaap.nl/wp-admin/admin.php?page=wppa_options



Test script:
---------------
// Get exif data
$exif = exif_read_data( $file, 'EXIF' );

// $file contains the full path to a .jpg file.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-12 13:17 UTC] cmb@php.net
-Assigned To: +Assigned To: kalle
 [2018-07-12 13:17 UTC] cmb@php.net
Kalle, could you have a look at this issue, please?
 [2018-07-16 14:32 UTC] kalle@php.net
-Status: Assigned +Status: Feedback
 [2018-07-16 14:32 UTC] kalle@php.net
Hi, whenever I try to access the linked .jpg's, I get a WP login page, any chance you can share them in a non protected space or zip them all?

Thanks
 [2018-07-17 09:26 UTC] opajaap at opajaap dot nl
-Status: Feedback +Status: Assigned
 [2018-07-17 09:26 UTC] opajaap at opajaap dot nl
Sorry, they are no longer there. Try https://betatest.opajaap.nl/wp-content/wppa-depot/opajaap/phpbug.zip this zip contains 5 of them.

FYI: Seems to be fixed in php 7.2.7
 [2018-07-17 15:55 UTC] kalle@php.net
Thanks for the zip! I will try take a look if there is something obviously wrong in ext/exif.

Ps. I think the reason its fixed in newer versions is due to stas@ security fixes that could have flipped the coin and actually make them work.
 [2018-07-25 07:24 UTC] jbe at geo6 dot be
I have the same issue since a few days.

Here is my PHP version :

PHP 7.2.7-2+0~20180714182401.1+jessie~1.gbp3fcba8 (cli) (built: Jul 15 2018 13:57:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.7-2+0~20180714182401.1+jessie~1.gbp3fcba8, Copyright (c) 1999-2018, by Zend Technologies
 [2018-10-17 22:08 UTC] gino0631 at centaurus dot cloud
It seems this issue is still present in PHP 7.2.11, e.g. with the sample image provided in this comment: https://github.com/gino0631/nextcloud-metadata/issues/19#issuecomment-414079570
 [2018-10-23 09:45 UTC] mike dot blomgren at tornado dot se
exif_read_data does not read all EXIF information in certain JPEG files.

Sample JPG here, that has the problem:
https://www.tornado.se/piwigo/tools/sample.jpg

Using exif_read_data produces the following output of 'sample.jpg':
https://www.tornado.se/piwigo/tools/metadata.php

I.e. it is not complete (using print_r and var_dump). The apache server produces the followong errors in error_log:

[Tue Oct 23 11:38:47.425214 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP Warning:  read_exif_data(sample.jpg): Process tag(x010D=DocumentNam): Illegal components(0) in /var/wwwtornado/htdocs/piwigo/tools/metadata.php on line 93
[Tue Oct 23 11:38:47.425234 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP Stack trace:
[Tue Oct 23 11:38:47.425240 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP   1. {main}() /var/wwwtornado/htdocs/piwigo/tools/metadata.php:0
[Tue Oct 23 11:38:47.425243 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP   2. read_exif_data() /var/wwwtornado/htdocs/piwigo/tools/metadata.php:93
[Tue Oct 23 11:38:47.425353 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP Notice:  Undefined index: IFD0 in /var/wwwtornado/htdocs/piwigo/tools/metadata.php on line 110
[Tue Oct 23 11:38:47.425364 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP Stack trace:
[Tue Oct 23 11:38:47.425370 2018] [php7:notice] [pid 3514] [client 195.198.34.135:1104] PHP   1. {main}() /var/wwwtornado/htdocs/piwigo/tools/metadata.php:0

Using exif_read_data seems to 'cut' up to a certain point of the EXIF header. Specifically I want to extract the DateTimeOriginal value, but php 7.2.11 isn't able to find the value. Using jhead or exiftool fully decodes all the EXIF headers.
 [2019-01-22 01:48 UTC] richard at dpiworld dot com
Same issue using 7.2.14 on CentOS 7.  Code and images work fine with PHP 5.4.16 but with PHP 7.2.14 exif text output is truncated so can't get GPS data. Can't extract thumbnails with exif_thumbnail().  These things are critical for my application and will delay moving to PHP 7.  EXEC exiftool is slow.   FYI, the vote system here gets an HTTP 500 error and fails.
 [2019-07-09 17:51 UTC] richard at dpiworld dot com
exif_thumbnail() fails with PHP 7.2.20 on CentOS 7. Works fine with same images with PHP 5.6.40.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 22:01:26 2019 UTC