Almost safe: a word on pseudo-normal floating point numbers

- . , - . - . , , , . , , , , . C GNU, . , .





  , . , - , , , Common Vulnerabilities and Exposures (CVE).





: double IEEE-754

64- double ( ) IEEE-754. 64- , , 11 / (exponent bits) 52 (significand bits). :





  • : ( ) ( ). .





  • / (denormal) : ( ). .





  • (Infinity): . , .





  • /Not a Number - (NaN): . , .





  • : . , .





; ( “integer”) , . . , , , . - .





double



: long double



. (extended precision) IEEE-754 , . , ; . (double extended-precision) Intel.





Intel

4.2 Intel 64 IA-32 80- , 1.





 





Figure 1: Layout of double extended precision floating point number format from Intel.
1: Intel.

, , , long-double :





  • : ( ). . (integer bit) .





  • : . . .





  • : . , . .





  • (NaN): . , . .





  • : . . .





:





  • , , NaN ?





  • , ?





  •  





. !





8.2.2 « - » Intel 64 IA-32 , . , Intel (floating point unit - FPU) , -NaN ( NaN ), - ( ) /unnormal ( ). FPU - ( ) , , . 387 FPU.





 - , , . ; , FPU . - , - .





- ?

, . -NaN - NaN? - ? (unnormal) ? ? ? ?





, . , . , NaN ( , NaN), , NaN, .





?

, . C, , 6.2.6 , , « », . FPU long double, , long double . , , , . , , long double , , . , fpclassify , , , .





,

, NaN, GNU (GCC) , . __builtin_isnanl, . ( NaN), (parity flag), , , , , - NaN. - - , , NaN.





  C GNU (glibc), , , . , , NaN __isnanl



__fpclassify



. , FPU - , . , - (, , -NaN), «» - !





( )

isnanl glibc , long double. , long double, , isnanl, , , .





CVE-2020-10029 CVE-2020-29573. CVE ( printf ) . CVE-2020-10029, - NaN. , .





  CVE-2020-29573 . glibc isnanf



, isnan



isnanl



C99 isnan



, . isnan C99, __builtin_isnan



, . CVE-2020-29573, - .





CVE ( GNU) C. glibc GCC , NaN C. , libm NaN . , ; , . , , .





 , , , -NaN -. , , , , .






- ++ ? , http- " "; .





"C++ Developer. Basic"





  • . 1





  • . 2









All Articles