php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78083 exif_read_data() corrupt EXIF header: maximum directory nesting level reached
Submitted: 2019-05-29 16:53 UTC Modified: 2021-04-07 02:32 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:2 (28.6%)
Same OS:1 (14.3%)
From: fermin at ares dot uy Assigned: cmb (profile)
Status: Closed Package: EXIF related
PHP Version: 7.3.5 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 50 = ?
Subscribe to this entry?

 
 [2019-05-29 16:53 UTC] fermin at ares dot uy
Description:
------------
When using the function "exif_read_data()" on certain jpg images it outputs this warning:

"Warning: exif_read_data(php7D62.tmp): corrupt EXIF header: maximum directory nesting level reached in \path\to\index.php on line 4"

And the metadata field 'title' does not show up on the resulting array.

You can download a problematic image for testing here https://ares.uy/P1110193.JPG

Test script:
---------------
<?php
if (!empty($_FILES)) {
  $imagen = $_FILES['imagen']['tmp_name'];
  $metadata = exif_read_data($imagen, 0, true);
  highlight_string("<?php\n\$metadata =\n" . var_export($metadata, true) . ";\n?>");
}
?>

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>EXIF TEST</title>
  </head>
  <body>
    <form action="/" method="post" enctype="multipart/form-data">
      <input type="file" name="imagen" value="">
      <input type="submit" name="" value="Print EXIF">
    </form>
  </body>
</html>


Expected result:
----------------
No warning message and the complete list of metadata fields on the array outputted by the function exif_read_data.

Actual result:
--------------
Warning message and incomplete metadata array.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-24 09:02 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Windows 10 +Operating System: *
 [2020-07-24 09:02 UTC] cmb@php.net
Indeed, that appears to be a bug – exiftool processes the image
just fine.
 [2020-08-31 07:43 UTC] nikic@php.net
On current 7.3 HEAD the "maximum directory nesting level" warning no longer occurs, but the output still seems to be corrupted: https://gist.github.com/nikic/4759bc05f118e0d4e59b54182c3da8f1

The "Title" is present, but probably filled with null bytes. There's a lot of "UndefinedTag" going on as well.
 [2020-08-31 07:59 UTC] nikic@php.net
Or is that actually the expected output? I see that exiftool only prints an empty title as well.
 [2020-08-31 08:50 UTC] cmb@php.net
That output looks actually good to me (besides that exiftool
supports way more tags than we do[1]).

[1] <https://exiftool.org/TagNames/EXIF.html>
 [2021-02-26 12:17 UTC] cmb@php.net
-Status: Verified +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-26 12:17 UTC] cmb@php.net
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.
 [2021-04-07 02:32 UTC] fermin at ares dot uy
-Status: No Feedback +Status: Closed
 [2021-04-07 02:32 UTC] fermin at ares dot uy
The issue seems to be resolved on PHP version 8.0.3. Closing the bug report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC