Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/time Fix reversed oveflow check.
details: https://anonhg.NetBSD.org/src/rev/14c1d9b6c6c4
branches: trunk
changeset: 760880:14c1d9b6c6c4
user: christos <christos%NetBSD.org@localhost>
date: Sat Jan 15 15:42:10 2011 +0000
description:
Fix reversed oveflow check.
diffstat:
lib/libc/time/localtime.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (42 lines):
diff -r 1bc0a1cc5cd2 -r 14c1d9b6c6c4 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sat Jan 15 13:54:52 2011 +0000
+++ b/lib/libc/time/localtime.c Sat Jan 15 15:42:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $ */
+/* $NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.9";
#else
-__RCSID("$NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.54 2011/01/15 15:42:10 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1704,8 +1704,10 @@
int number0;
number0 = *number;
+ if (delta < 0 ? number0 < INT_MIN - delta : INT_MAX - delta < number0)
+ return 1;
*number += delta;
- return (*number < number0) != (delta < 0);
+ return 0;
}
static int
@@ -1714,8 +1716,10 @@
long number0;
number0 = *number;
+ if (delta < 0 ? number0 < LONG_MIN - delta : LONG_MAX - delta < number0)
+ return 1;
*number += delta;
- return (*number < number0) != (delta < 0);
+ return 0;
}
static int
Home |
Main Index |
Thread Index |
Old Index