|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20907 Failure of the storing Exif tag data elemens after the 2nd
Submitted: 2002-12-09 08:41 UTC Modified: 2005-02-01 22:56 UTC
From: m-arai at sco dot bekkoame dot ne dot jp Assigned:
Status: Closed Package: EXIF related
PHP Version: 4.3.0RC2 OS: FreeBSD 4.6-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: m-arai at sco dot bekkoame dot ne dot jp
New email:
PHP Version: OS:


 [2002-12-09 08:41 UTC] m-arai at sco dot bekkoame dot ne dot jp

In exif_iif_add_value() , since the increment of value pointer is not
appropriately performed, when length is larger than 1, the elements
after 2nd are overwritten by 1st element.

ex) GPS.GPSLatitude
if the real value of GPSLatitude is "36/1 43859/1000 0/1",

  $exif = exif_read_data('filename',0,true);
  $lad = $exif["GPS"]["GPSLatitude"][0];
  $lam = $exif["GPS"]["GPSLatitude"][1];
  $las = $exif["GPS"]["GPSLatitude"][2];

"$lad,$lam,$las" has to be "36/1 43859/1000 0/1". 
But, it is set to "36/1 36/1 36/1" in the present.

adhoc patch

--- ext/exif/exif.c.orig        Mon Dec  9 22:01:12 2002
+++ ext/exif/exif.c     Mon Dec  9 22:03:10 2002
@@ -1520,6 +1520,7 @@
 static void exif_iif_add_value(image_info_type *image_info, int section_index, char *name, int tag, int format, size_t len
gth, void* value, int motorola_intel TSRMLS_DC)
        size_t index;
+       void   *vptr;
        image_info_value *info_value;
        image_info_data  *info_data;
        image_info_data  *list;
@@ -1604,35 +1605,36 @@
                        } else {
                                info_value = &info_data->value;
-                       for (index=0; index<length; index++) {
+                       /**************/
+                       for (index=0,vptr=value; index<length; index++, vptr+=php_tiff_bytes_per_format[format]) {
                                if (length>1) {
                                        info_value = &info_data->value.list[index];
                                switch (format) {
                                        case TAG_FMT_USHORT:
-                                               info_value->u = php_ifd_get16u(value, motorola_intel);
+                                               info_value->u = php_ifd_get16u(vptr, motorola_intel);
                                        case TAG_FMT_ULONG:
-                                               info_value->u = php_ifd_get32u(value, motorola_intel);
+                                               info_value->u = php_ifd_get32u(vptr, motorola_intel);
                                        case TAG_FMT_URATIONAL:
-                                               info_value->ur.num = php_ifd_get32u(value, motorola_intel);
-                                               info_value->ur.den = php_ifd_get32u(4+(char *)value, motorola_intel);
+                                               info_value->ur.num = php_ifd_get32u(vptr, motorola_intel);
+                                               info_value->ur.den = php_ifd_get32u(4+(char *)vptr, motorola_intel);
                                        case TAG_FMT_SSHORT:
-                                               info_value->i = php_ifd_get16s(value, motorola_intel);
+                                               info_value->i = php_ifd_get16s(vptr, motorola_intel);
                                        case TAG_FMT_SLONG:
-                                               info_value->i = php_ifd_get32s(value, motorola_intel);
+                                               info_value->i = php_ifd_get32s(vptr, motorola_intel);
                                        case TAG_FMT_SRATIONAL:
-                                               info_value->sr.num = php_ifd_get32u(value, motorola_intel);
-                                               info_value->sr.den = php_ifd_get32u(4+(char *)value, motorola_intel);
+                                               info_value->sr.num = php_ifd_get32u(vptr, motorola_intel);
+                                               info_value->sr.den = php_ifd_get32u(4+(char *)vptr, motorola_intel);
                                        case TAG_FMT_SINGLE:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-09 12:31 UTC] m-arai at sco dot bekkoame dot ne dot jp
 The tag number has misplaced in ext/exif/exif.c.

--- exif.c.orig Wed Nov 27 11:43:21 2002
+++ exif.c      Tue Dec 10 02:45:17 2002
@@ -765,8 +765,8 @@
   { 0x0000, "GPSVersion"},
   { 0x0001, "GPSLatitudeRef"},
   { 0x0002, "GPSLatitude"},
-  { 0x0003, "GPSLongitude"},
-  { 0x0004, "GPSLongitudeRef"},
+  { 0x0003, "GPSLongitudeRef"},
+  { 0x0004, "GPSLongitude"},
   { 0x0005, "GPSAltitudeRef"},
   { 0x0006, "GPSAltitude"},
   { 0x0007, "GPSTimeStamp"},
 [2002-12-09 12:34 UTC]
Could you please provide an image that could be used to test this?
 [2002-12-09 13:00 UTC] m-arai at sco dot bekkoame dot ne dot jp
You can get images I used to test. Please see following URLs.

This BBS system (written in perl) generates links to map service WEB site from Exif GPS info. of posted imagefile,
and displays Date,Software,Location,Make/Model,Usercomment...
 [2002-12-09 18:10 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jun 09 14:03:38 2023 UTC