]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
msun: signed overflow in atan2
authoreadler <eadler@FreeBSD.org>
Wed, 14 Feb 2018 07:59:30 +0000 (07:59 +0000)
committereadler <eadler@FreeBSD.org>
Wed, 14 Feb 2018 07:59:30 +0000 (07:59 +0000)
commitb21ccf63f28a3a4692d8a31419e0a725a1b1a800
tree20f31d7b8a1d07977e6a8901c4d3b6171f112039
parent707bc0b7a7aaf212fe6c3a2f3886b09baf5f33b0
msun: signed overflow in atan2

As a component of atan2(y, x), the case of x == 1.0 is farmed out to
atan(y). The current implementation of this comparison is vulnerable
to signed integer underflow (that is, undefined behavior), and it's
performed in a somewhat more complicated way than it need be. Change
it to not be quite so cute, rather directly comparing the high/low
bits of x to the specific IEEE-754 bit pattern that encodes 1.0.

Note that while there are three different e_atan* files in the
relevant directory, only this one needs fixing. e_atan2f.c already
compares against the full bit pattern encoding 1.0f, while
e_atan2l.cuses bitwise-ands/ors/nots and so doesn't require a change.

Closes #130

Submitted by: Jeff Walden (@jswalden github PR #130)
Reviewed by: bde
MFC After: 1 month
lib/msun/src/e_atan2.c