File tree 3 files changed +38
-2
lines changed 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ PHP NEWS
20
20
- CURL:
21
21
. Fixed bug #79033 (Curl timeout error with specific url and post). (cmb)
22
22
23
+ - Exif:
24
+ . Fixed bug #79046 (NaN to int cast undefined behavior in exif). (Nikita)
25
+
23
26
- Fileinfo:
24
27
. Fixed bug #74170 (locale information change after mime_content_type).
25
28
(Sergei Turchanov)
Original file line number Diff line number Diff line change @@ -1699,7 +1699,7 @@ static int exif_rewrite_tag_format_to_unsigned(int format)
1699
1699
1700
1700
/* Use saturation for out of bounds values to avoid UB */
1701
1701
static size_t float_to_size_t (float x ) {
1702
- if (x < 0.0f ) {
1702
+ if (x < 0.0f || zend_isnan ( x ) ) {
1703
1703
return 0 ;
1704
1704
} else if (x > (float ) SIZE_MAX ) {
1705
1705
return SIZE_MAX ;
@@ -1709,7 +1709,7 @@ static size_t float_to_size_t(float x) {
1709
1709
}
1710
1710
1711
1711
static size_t double_to_size_t (double x ) {
1712
- if (x < 0.0 ) {
1712
+ if (x < 0.0 || zend_isnan ( x ) ) {
1713
1713
return 0 ;
1714
1714
} else if (x > (double ) SIZE_MAX ) {
1715
1715
return SIZE_MAX ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #79046: NaN to int cast undefined behavior in exif
3
+ --FILE--
4
+ <?php
5
+ var_dump (exif_read_data ('data://image/tiff;base64,TU0AKgAAAA7//wAAANUAAQERAAsAAAABAAD4fwAAAA4A ' ));
6
+ ?>
7
+ --EXPECT--
8
+ array(8) {
9
+ ["FileDateTime"]=>
10
+ int(0)
11
+ ["FileSize"]=>
12
+ int(33)
13
+ ["FileType"]=>
14
+ int(8)
15
+ ["MimeType"]=>
16
+ string(10) "image/tiff"
17
+ ["SectionsFound"]=>
18
+ string(24) "ANY_TAG, IFD0, THUMBNAIL"
19
+ ["COMPUTED"]=>
20
+ array(2) {
21
+ ["IsColor"]=>
22
+ int(0)
23
+ ["ByteOrderMotorola"]=>
24
+ int(1)
25
+ }
26
+ ["StripOffsets"]=>
27
+ float(NAN)
28
+ ["THUMBNAIL"]=>
29
+ array(1) {
30
+ ["StripOffsets"]=>
31
+ float(NAN)
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments