summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Hartmeier <dhartmei@cvs.openbsd.org>2004-04-25 21:05:02 +0000
committerDaniel Hartmeier <dhartmei@cvs.openbsd.org>2004-04-25 21:05:02 +0000
commitfa1ee3d7c6ed1a699c06734a736bdc52c235cca5 (patch)
tree3aa39bf5c3705672a13d4ed9d4b595463168614f /lib
parent3ad871c3cfac76537d0a66acb38e46fade2cfd81 (diff)
add/subtract ULONG_MAX + 1 on over/underflows, fixes float -> quad
conversion in libc, reported by Marcus Holland-Moritz, ok beck@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/quad/fixunsdfdi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/quad/fixunsdfdi.c b/lib/libc/quad/fixunsdfdi.c
index 83946d7e9e4..9eb5e8f2e66 100644
--- a/lib/libc/quad/fixunsdfdi.c
+++ b/lib/libc/quad/fixunsdfdi.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fixunsdfdi.c,v 1.3 2003/06/02 20:18:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: fixunsdfdi.c,v 1.4 2004/04/25 21:05:01 dhartmei Exp $";
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
@@ -81,11 +81,11 @@ __fixunsdfdi(x)
x -= (double)t.uq;
if (x < 0) {
t.ul[H]--;
- x += ULONG_MAX;
+ x += ULONG_MAX + 1;
}
if (x > ULONG_MAX) {
t.ul[H]++;
- x -= ULONG_MAX;
+ x -= ULONG_MAX + 1;
}
t.ul[L] = (u_long)x;
return (t.uq);