|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77184 Unsigned rational numbers are written out as signed rationals
Submitted: 2018-11-21 21:35 UTC Modified: -
From: cmbasnett at gmail dot com Assigned:
Status: Closed Package: EXIF related
PHP Version: 7.3Git-2018-11-21 (Git) OS: macOS Mojave
Private report: No CVE-ID: None
 [2018-11-21 21:35 UTC] cmbasnett at gmail dot com
I discovered the bug while reading EXIF data from this file:

The correct value of the GPSLongitude value in DMS format is:

122° 23' 38.1732"

For GPSLongitude, PHP's exif_read_data format returns the following:

array:3 [
 0 => "122/1"
 1 => "23/1"
 2 => "-1622773725/70000000"

Note the negative value in there. There should be no negative values since GPSLongitude is an array of unsigned rationals. As a result, the value calculated for the seconds component is -23.1824, which is incorrect.

The problem is that the bytes for the values are being written out as a signed integer instead of an unsigned integer. The values are being converted to a string using the wrong format specifier ("%i" instead of "%u"), so the fix is to simply fix the format specifier.


php-exif-urational-fix (last revision 2018-11-21 21:35 UTC by )

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-26 21:49 UTC]
Automatic comment on behalf of
Log: Fixed bug #77184
 [2018-11-26 21:49 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 17:01:28 2024 UTC