aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-08-20 19:41:15 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-08-20 19:41:15 +0000
commitc980f2f4fe0f5d301f706017a1f7e4e942193ec0 (patch)
treea8a3c9c159747a9eed2acaa20a65e19d8b23a5c4
parent0716c4fc9fff70870e28f84d18ddbce1db162101 (diff)
downloadglibc-c980f2f4fe0f5d301f706017a1f7e4e942193ec0.zip
glibc-c980f2f4fe0f5d301f706017a1f7e4e942193ec0.tar.gz
glibc-c980f2f4fe0f5d301f706017a1f7e4e942193ec0.tar.bz2
Fix cproj handling of (finite, NaN) arguments (bug 15531).
-rw-r--r--ChangeLog8
-rw-r--r--NEWS2
-rw-r--r--math/libm-test.inc40
-rw-r--r--math/s_cproj.c4
-rw-r--r--math/s_cprojf.c4
-rw-r--r--math/s_cprojl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_cprojl.c4
7 files changed, 53 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 70771d6..5773042 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-08-20 Joseph Myers <joseph@codesourcery.com>
+ [BZ #15531]
+ * math/s_cproj.c (__cproj): Only return an infinity if one part of
+ argument is infinite.
+ * math/s_cprojf.c (__cprojf): Likewise.
+ * math/s_cprojl.c (__cprojl): Likewise.
+ * sysdeps/ieee754/ldbl-128ibm/s_cprojl.c (__cprojl): Likewise.
+ * math/libm-test.inc (cproj_test_data): Add more tests.
+
* sysdeps/unix/sysv/linux/mmap64.c: Include <string.h>.
* sysdeps/unix/sysv/linux/mmap64.c (__mmap64)
diff --git a/NEWS b/NEWS
index 9f44db0..4b79c3d 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Version 2.19
* The following bugs are resolved with this release:
- 14699, 15749
+ 14699, 15531, 15749
* CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes
to the d_name member of struct dirent, or omit the terminating NUL
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 851f1be..25ea336 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -7066,11 +7066,51 @@ static const struct test_c_c_data cproj_test_data[] =
TEST_c_c (cproj, qnan_value, qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_zero, qnan_value, plus_zero, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_zero, qnan_value, minus_zero, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, qnan_value, plus_zero, qnan_value, plus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, qnan_value, minus_zero, qnan_value, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, 1.0, qnan_value, 1.0, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, -1.0, qnan_value, -1.0, qnan_value, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, qnan_value, 1.0, qnan_value, 1.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, qnan_value, -1.0, qnan_value, -1.0, NO_INEXACT_EXCEPTION),
+
TEST_c_c (cproj, plus_infty, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
TEST_c_c (cproj, plus_infty, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
TEST_c_c (cproj, minus_infty, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
TEST_c_c (cproj, minus_infty, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_infty, plus_zero, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_infty, minus_zero, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, plus_zero, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, minus_zero, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, plus_zero, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_zero, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_zero, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_zero, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, plus_infty, 1.0, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_infty, -1.0, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, 1.0, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, -1.0, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, 1.0, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, 1.0, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, -1.0, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, -1.0, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, plus_infty, qnan_value, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, plus_infty, -qnan_value, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, qnan_value, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, minus_infty, -qnan_value, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
+ TEST_c_c (cproj, qnan_value, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, qnan_value, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, -qnan_value, plus_infty, plus_infty, 0.0, NO_INEXACT_EXCEPTION),
+ TEST_c_c (cproj, -qnan_value, minus_infty, plus_infty, minus_zero, NO_INEXACT_EXCEPTION),
+
TEST_c_c (cproj, 1.0, 0.0, 1.0, 0.0, NO_INEXACT_EXCEPTION),
TEST_c_c (cproj, 2.0, 3.0, 2.0, 3.0, NO_INEXACT_EXCEPTION),
};
diff --git a/math/s_cproj.c b/math/s_cproj.c
index c0be461..98f1a4c 100644
--- a/math/s_cproj.c
+++ b/math/s_cproj.c
@@ -24,9 +24,7 @@
__complex__ double
__cproj (__complex__ double x)
{
- if (isnan (__real__ x) && isnan (__imag__ x))
- return x;
- else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__isinf_ns (__real__ x) || __isinf_ns (__imag__ x))
{
__complex__ double res;
diff --git a/math/s_cprojf.c b/math/s_cprojf.c
index 188bbe3..e4dbc18 100644
--- a/math/s_cprojf.c
+++ b/math/s_cprojf.c
@@ -24,9 +24,7 @@
__complex__ float
__cprojf (__complex__ float x)
{
- if (isnan (__real__ x) && isnan (__imag__ x))
- return x;
- else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__isinf_nsf (__real__ x) || __isinf_nsf (__imag__ x))
{
__complex__ float res;
diff --git a/math/s_cprojl.c b/math/s_cprojl.c
index fbdf279..b564a83 100644
--- a/math/s_cprojl.c
+++ b/math/s_cprojl.c
@@ -24,9 +24,7 @@
__complex__ long double
__cprojl (__complex__ long double x)
{
- if (isnan (__real__ x) && isnan (__imag__ x))
- return x;
- else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__isinf_nsl (__real__ x) || __isinf_nsl (__imag__ x))
{
__complex__ long double res;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_cprojl.c b/sysdeps/ieee754/ldbl-128ibm/s_cprojl.c
index 3b4af54..a344e92 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_cprojl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_cprojl.c
@@ -24,9 +24,7 @@
__complex__ long double
__cprojl (__complex__ long double x)
{
- if (isnan (__real__ x) && isnan (__imag__ x))
- return x;
- else if (!isfinite (__real__ x) || !isfinite (__imag__ x))
+ if (__isinf_nsl (__real__ x) || __isinf_nsl (__imag__ x))
{
__complex__ long double res;