|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79907 exif_read_data() corrupt EXIF header: maximum directory nesting level reached
Submitted: 2020-07-28 12:29 UTC Modified: 2021-03-07 04:22 UTC
Avg. Score:4.2 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:3 (50.0%)
From: php at lho dot io Assigned: cmb (profile)
Status: No Feedback Package: EXIF related
PHP Version: 7.4.8 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-07-28 12:29 UTC] php at lho dot io
Might be the same problem as in, 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:

Test script:
$exif = exif_read_data('DSCF1362.jpg', 0, true);
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        echo "$key.$name: ";
        echo "<br />\n";

Expected result:
Should read all EXIF data correctly

Actual result:
Error message and missing data


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-09 15:10 UTC] lookingdown at mail dot com
line 69

changing this to 


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 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-08-12 08:01 UTC]
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-12 08:13 UTC]
The following pull request has been associated:

Patch Name: Make MAX_IFD_NESTING_LEVEL an actual nesting level
On GitHub:
 [2020-08-12 08:15 UTC] php at lho dot io
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.
 [2020-08-12 08:16 UTC]
> I suspect that is not what was intended.

Probably not, see bug #31986, and also bug #28451; the fix for the
latter introduced the constant with value 5[1].

[1] <;a=commit;h=ecb9f8668db5cc05734aa77b406028ca38ae2284>
 [2021-02-26 12:19 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-26 12:19 UTC]
Is this resolved as of PHP 7.3.23 and 7.4.11, respectively, or is
there still an issue?
 [2021-03-07 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Mar 27 15:04:44 2023 UTC