Bug #79907 [Com]: exif_read_data() corrupt EXIF header: maximum directory nesting level reached
| From: | php at lho dot io | Date: | Wed, 12 Aug 2020 08:15:40 +0000 |
| Subject: | Bug #79907 [Com]: exif_read_data() corrupt EXIF header: maximum directory nesting level reached | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228533@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79907&edit=1
ID: 79907
Comment by: php at lho dot io
Reported by: php at lho dot io
Summary: exif_read_data() corrupt EXIF header: maximum
directory nesting level reached
Status: Open
Type: Bug
Package: EXIF related
Operating System: Linux
PHP Version: 7.4.8
Block user comment: N
Private report: N
New Comment:
I can confirm increasing the nesting limit works for my files. Is it possible for this limit to get
raised upstream? I'm guessing that in the future more cameras are only going to add more
metadata to the pictures and it'd great for user experience if it worked out of the box.
Previous Comments:
------------------------------------------------------------------------
[2020-08-12 08:13:40] nikic@php.net
The following pull request has been associated:
Patch Name: Make MAX_IFD_NESTING_LEVEL an actual nesting level
On GitHub: https://github.com/php/php-src/pull/5976
Patch: https://github.com/php/php-src/pull/5976.patch
------------------------------------------------------------------------
[2020-08-12 08:01:39] nikic@php.net
Looks like ifd_nesting_level only ever gets incremented, so MAX_IFD_NESTING_LEVEL is not really a
"nesting level" but rather MAX_NUMBER_OF_IFD_TAGS.
I suspect that is not what was intended.
------------------------------------------------------------------------
[2020-08-09 15:10:28] lookingdown at mail dot com
ext/exif/exif.c
line 69
#define MAX_IFD_NESTING_LEVEL 150
changing this to
#define MAX_IFD_NESTING_LEVEL 300
Should cover most EXIF value scenarios, f.ex. Panasonic GH4 with added GPS info have 244 entries.
After value change of MAX_IFD_NESTING_LEVEL to desired value f.ex. 300 in exif.c recompile module
and replace exif.so in extension dir of PHP installation.
Tested with 7.3 from github src repo. Seems to do the trick, the problem have nothing to do with
inherent limitations of PHP as suggested elsewhere, just this restriction/limitation hardcoded in
extension exif.
------------------------------------------------------------------------
[2020-07-28 12:29:13] php at lho dot io
Description:
------------
Might be the same problem as in https://bugs.php.net/bug.php?id=78083, I'm no
EXIF expert. In that case, let the reference photo be another datapoint.
When reading exif data from an image (which works fine in exiftool), I get the error:
PHP Warning: exif_read_data(DSCF1362.jpg): corrupt EXIF header: maximum directory nesting level
reached in /home/leo/Downloads/test/script.php on line 2
Geodata is missing in the result.
Most images taken with the same camera (Fuji X-T30) and edited with darktable work, but I have 8
images where this error happens. Upon request, I can provide additional images. Link to the image
causing this specific error: https://gofile.io/d/A42LUr
Test script:
---------------
<?php
$exif = exif_read_data('DSCF1362.jpg', 0, true);
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: ";
print_r($val);
echo "<br />\n";
}
}
?>
Expected result:
----------------
Should read all EXIF data correctly
Actual result:
--------------
Error message and missing data
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79907&edit=1