Bug #79336 [Com]: ext/exif/tests/bug79046.phpt fails on Big endian arch
| From: | vibhutisawant18 at gmail dot com | Date: | Wed, 25 Mar 2020 05:50:11 +0000 |
| Subject: | Bug #79336 [Com]: ext/exif/tests/bug79046.phpt fails on Big endian arch | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226251@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79336&edit=1
ID: 79336
Comment by: vibhutisawant18 at gmail dot com
Reported by: vibhutisawant18 at gmail dot com
Summary: ext/exif/tests/bug79046.phpt fails on Big endian
arch
Status: Open
Type: Bug
Package: EXIF related
Operating System: Ubuntu 16.04
PHP Version: master-Git-2020-03-03 (Git)
Block user comment: N
Private report: N
New Comment:
@nikic following observations were made wrt the TC behaviour on Big endian
System(s390x)
char data type is signed(-128 to 127) by default on x86 arch whereas char is
treated as unsigned(0 to 255) on s390x.
In function static float php_ifd_get_float(char *data) of
php-src/ext/exif/exif.c ,the 3rd byte (data[2]) is referring to -8(Hex:
fffffff8 ),where as its referred to 248 (Hex: f8) on s390x as char is treated as unsigned char.
Hence byte swap won't solve the issue, could you please guide us on what could possibly help to
tackle the above
scenario?
Previous Comments:
------------------------------------------------------------------------
[2020-03-09 05:57:40] vibhutisawant18 at gmail dot com
I added a byte swap in php_ifd_get_float() and php_ifd_get_double(), however same behavior
continues to persist.
Could you please provide with some more insights.
------------------------------------------------------------------------
[2020-03-03 10:45:48] nikic@php.net
You likely need to introduce a byte-swap into php_ifd_get_float() and php_ifd_get_double() on
big-endian architectures.
------------------------------------------------------------------------
[2020-03-03 10:40:51] vibhutisawant18 at gmail dot com
Description:
------------
NaN to int cast undefined behavior in exif [ext/exif/tests/bug79046.phpt]
Above TC fails on big endian architecture, the expected value for StripOffsets is NAN whereas that
returned on Big endian is float(8.9143601808023E-41)
Could you please guide us on how to go about it.
PFA test case logs on Little and Big endian Architecture.
Little Endian:
test@a2a9ec71b826:~/php/php-src$ ./sapi/cli/php -f "ext/exif/tests/bug79046.phpt"
--TEST--
Bug #79046: NaN to int cast undefined behavior in exif
--FILE--
array(8) {
["FileDateTime"]=>
int(0)
["FileSize"]=>
int(33)
["FileType"]=>
int(8)
["MimeType"]=>
string(10) "image/tiff"
["SectionsFound"]=>
string(24) "ANY_TAG, IFD0, THUMBNAIL"
["COMPUTED"]=>
array(2) {
["IsColor"]=>
int(0)
["ByteOrderMotorola"]=>
int(1)
}
["StripOffsets"]=>
float(NAN)
["THUMBNAIL"]=>
array(1) {
["StripOffsets"]=>
float(NAN)
}
}
Big endian:
--TEST--
Bug #79046: NaN to int cast undefined behavior in exif
--FILE--
array(8) {
["FileDateTime"]=>
int(0)
["FileSize"]=>
int(33)
["FileType"]=>
int(8)
["MimeType"]=>
string(10) "image/tiff"
["SectionsFound"]=>
string(24) "ANY_TAG, IFD0, THUMBNAIL"
["COMPUTED"]=>
array(2) {
["IsColor"]=>
int(0)
["ByteOrderMotorola"]=>
int(1)
}
["StripOffsets"]=>
float(8.9143601808023E-41)
["THUMBNAIL"]=>
array(1) {
["StripOffsets"]=>
float(8.9143601808023E-41)
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79336&edit=1