php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79279 ext/exif/tests/float_cast_overflow.phpt TC fails on Big endian architecture
Submitted: 2020-02-18 09:23 UTC Modified: 2020-04-29 08:02 UTC
From: vibhutisawant18 at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *Math Functions
PHP Version: master-Git-2020-02-18 (Git) OS: Ubuntu 16.04
Private report: No CVE-ID: None
 [2020-02-18 09:23 UTC] vibhutisawant18 at gmail dot com
Description:
------------
ext/exif/tests/float_cast_overflow.phpt TC fails on Big endian architecture.
The TIFF image used in the Test case is of Little Endian format

test@8e9e8232f7f2:~/php/php-src/ext/exif/tests$ xxd float_cast_overflow.tiff | more
00000000: 4949 2a00 8800 0000 0400 0001 0300 0100  II*.............
00000010: 0000 0100 0000 0101 0b00 0100 0000 0100  ................
00000020: 00f7 0201 0300 00e4 0700 009d 3920 3a35  ............9 :5
00000030: 203a 3533 001d 0010 0005 0000 0080 0020   :53...........
00000040: 2000 0000 0800 0000 0000 0000 0000 0000   ...............
00000050: 0028 1100 0000 0000 0000 0000 0000 0000  .(..............
00000060: 0000 0000 9cff 0000 0000 8000 2020 0000  ............  ..
00000070: e407 0000 9d39 203a 3533 001d 0010 0005  .....9 :53......
00000080: 0000 0080 0020 2000 0000 0800 0000       .....  .......
PFB the test log for ext/exif/tests/float_cast_overflow.phpt on Ubuntu:16.04

test@8e9e8232f7f2:~/php/php-src$ sapi/cli/php ext/exif/tests/float_cast_overflow.phpt
--TEST--
Overflow in float to int cast
--FILE--
array(8) {
  ["FileName"]=>
  string(24) "float_cast_overflow.tiff"
  ["FileDateTime"]=>
  int(1581566800)
  ["FileSize"]=>
  int(142)
  ["FileType"]=>
  int(7)
  ["MimeType"]=>
  string(10) "image/tiff"
  ["SectionsFound"]=>
  string(24) "ANY_TAG, IFD0, THUMBNAIL"
  ["COMPUTED"]=>
  array(5) {
    ["html"]=>
    string(20) "width="1" height="1""
    ["Height"]=>
    int(1)
    ["Width"]=>
    int(1)
    ["IsColor"]=>
    int(0)
    ["ByteOrderMotorola"]=>
    int(0)
  }
  ["THUMBNAIL"]=>
  array(2) {
    ["ImageWidth"]=>
    int(1)
    ["ImageLength"]=>
    float(2.3510579257887E-38)
  }
}
--EXPECTF--
array(8) {
  ["FileName"]=>
  string(24) "float_cast_overflow.tiff"
  ["FileDateTime"]=>
  int(%d)
  ["FileSize"]=>
  int(142)
  ["FileType"]=>
  int(7)
  ["MimeType"]=>
  string(10) "image/tiff"
  ["SectionsFound"]=>
  string(24) "ANY_TAG, IFD0, THUMBNAIL"
  ["COMPUTED"]=>
  array(5) {
    ["html"]=>
    string(20) "width="1" height="1""
    ["Height"]=>
    int(1)
    ["Width"]=>
    int(1)
    ["IsColor"]=>
    int(0)
    ["ByteOrderMotorola"]=>
    int(0)
  }
  ["THUMBNAIL"]=>
  array(2) {
    ["ImageWidth"]=>
    int(1)
    ["ImageLength"]=>
    float(-2.5961487387524E+33)
  }
}



The ImagLength returned is 
["ImageLength"]=>
    float(2.3510579257887E-38)
whereas ImageLength expected is
["ImageLength"]=>
    float(-2.5961487387524E+33) 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-18 09:43 UTC] vibhutisawant18 at gmail dot com
I have used imagemagick package to convert float_cast_overflow.tiff image to Big endian format, however the command failed with below error message:


test@8e9e8232f7f2:~/php/php-src$ convert ext/exif/tests/float_cast_overflow.tiff -define tiff:endian=msb msb.tif
convert: Sanity check on directory count failed, zero tag directories not supported. `TIFFFetchDirectory' @ error/tiff.c/TIFFErrors/568.
convert: Failed to read directory at offset 136. `TIFFReadDirectory' @ error/tiff.c/TIFFErrors/568.
convert: no images defined `msb.tif' @ error/convert.c/ConvertImageCommand/3210.

Also,
The File command mentions the direntries=0.

test@8e9e8232f7f2:~/php/php-src$ file ext/exif/tests/float_cast_overflow.tiff
ext/exif/tests/float_cast_overflow.tiff: TIFF image data, little-endian, direntries=0
 [2020-04-29 05:05 UTC] vibhutisawant18 at gmail dot com
This bug got fixed by this coomit
http://git.php.net/?p=php-src.git;a=commit;h=0b709e3409a1899caa6aaf3a5442e83524e2355c
 [2020-04-29 08:02 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-04-29 08:02 UTC] nikic@php.net
Thanks for the reminder, closing...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC