File tree 2 files changed +35
-2
lines changed 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -1669,7 +1669,7 @@ static int exif_rewrite_tag_format_to_unsigned(int format)
1669
1669
1670
1670
/* Use saturation for out of bounds values to avoid UB */
1671
1671
static size_t float_to_size_t (float x ) {
1672
- if (x < 0.0f ) {
1672
+ if (x < 0.0f || zend_isnan ( x ) ) {
1673
1673
return 0 ;
1674
1674
} else if (x > (float ) SIZE_MAX ) {
1675
1675
return SIZE_MAX ;
@@ -1679,7 +1679,7 @@ static size_t float_to_size_t(float x) {
1679
1679
}
1680
1680
1681
1681
static size_t double_to_size_t (double x ) {
1682
- if (x < 0.0 ) {
1682
+ if (x < 0.0 || zend_isnan ( x ) ) {
1683
1683
return 0 ;
1684
1684
} else if (x > (double ) SIZE_MAX ) {
1685
1685
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