91 lines
2.9 KiB
Diff
91 lines
2.9 KiB
Diff
From 3fc83feae0bc3fcfbb7cfc8a927bb4a888a7663b Mon Sep 17 00:00:00 2001
|
|
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
|
Date: Sun, 31 May 2020 07:51:23 +0200
|
|
Subject: [PATCH 006/147] Revert the check for NaN in %f format
|
|
|
|
Unfortunately -Ofast seems to break that check.
|
|
|
|
Fixes #11994
|
|
|
|
Reviewed-by: Paul Dale <paul.dale@oracle.com>
|
|
(Merged from https://github.com/openssl/openssl/pull/12003)
|
|
|
|
(cherry picked from commit 41dccd68b9b9b7622b26d264c5fa190aa5bd4201)
|
|
---
|
|
crypto/bio/b_print.c | 4 +---
|
|
test/bioprinttest.c | 33 ---------------------------------
|
|
2 files changed, 1 insertion(+), 36 deletions(-)
|
|
|
|
diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c
|
|
index 48556f7..2f68fe7 100644
|
|
--- a/crypto/bio/b_print.c
|
|
+++ b/crypto/bio/b_print.c
|
|
@@ -638,10 +638,8 @@ fmtfp(char **sbuffer,
|
|
/*
|
|
* By subtracting 65535 (2^16-1) we cancel the low order 15 bits
|
|
* of ULONG_MAX to avoid using imprecise floating point values.
|
|
- * The second condition is necessary to catch NaN values.
|
|
*/
|
|
- if (ufvalue >= (double)(ULONG_MAX - 65535) + 65536.0
|
|
- || !(ufvalue == ufvalue) /* NaN */) {
|
|
+ if (ufvalue >= (double)(ULONG_MAX - 65535) + 65536.0) {
|
|
/* Number too big */
|
|
return 0;
|
|
}
|
|
diff --git a/test/bioprinttest.c b/test/bioprinttest.c
|
|
index e37b854..e97de03 100644
|
|
--- a/test/bioprinttest.c
|
|
+++ b/test/bioprinttest.c
|
|
@@ -241,48 +241,15 @@ static int test_fp(int i)
|
|
return r;
|
|
}
|
|
|
|
-extern double zero_value;
|
|
-double zero_value = 0.0;
|
|
-
|
|
static int test_big(void)
|
|
{
|
|
char buf[80];
|
|
- double d, z, inf, nan;
|
|
|
|
/* Test excessively big number. Should fail */
|
|
if (!TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
"%f\n", 2 * (double)ULONG_MAX), -1))
|
|
return 0;
|
|
|
|
- d = 1.0;
|
|
- z = zero_value;
|
|
- inf = d / z;
|
|
- nan = z / z;
|
|
-
|
|
- /*
|
|
- * Test +/-inf, nan. Should fail.
|
|
- * Test +/-1.0, +/-0.0. Should work.
|
|
- */
|
|
- if (!TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", inf), -1)
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", -inf), -1)
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", nan), -1)
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", d), 8)
|
|
- || !TEST_str_eq(buf, "1.000000")
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", z), 8)
|
|
- || !TEST_str_eq(buf, "0.000000")
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", -d), 9)
|
|
- || !TEST_str_eq(buf, "-1.000000")
|
|
- || !TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
|
|
- "%f", -z), 8)
|
|
- || !TEST_str_eq(buf, "0.000000"))
|
|
- return 0;
|
|
-
|
|
return 1;
|
|
}
|
|
|
|
--
|
|
1.8.3.1
|
|
|