Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src avoid overflow during multiply. David Laight



details:   https://anonhg.NetBSD.org/src/rev/b5f2eecc1929
branches:  trunk
changeset: 552008:b5f2eecc1929
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Sep 15 23:38:20 2003 +0000

description:
avoid overflow during multiply.  David Laight

diffstat:

 lib/libc/gen/randomid.c |  6 +++---
 sys/netinet6/ip6_id.c   |  6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diffs (54 lines):

diff -r f92521848b88 -r b5f2eecc1929 lib/libc/gen/randomid.c
--- a/lib/libc/gen/randomid.c   Mon Sep 15 22:30:38 2003 +0000
+++ b/lib/libc/gen/randomid.c   Mon Sep 15 23:38:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: randomid.c,v 1.6 2003/09/13 21:29:57 itojun Exp $      */
+/*     $NetBSD: randomid.c,v 1.7 2003/09/15 23:38:20 itojun Exp $      */
 /*     $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $  */
 /*     $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $       */
 
@@ -88,7 +88,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: randomid.c,v 1.6 2003/09/13 21:29:57 itojun Exp $");
+__RCSID("$NetBSD: randomid.c,v 1.7 2003/09/15 23:38:20 itojun Exp $");
 #endif
 
 #include "namespace.h"
@@ -314,7 +314,7 @@
 
        for (i = 0; i <= n; i++) {
                /* Linear Congruential Generator */
-               p->ru_x = (p->ru_a * p->ru_x + p->ru_b) % p->ru_m;
+               p->ru_x = ((u_int64_t)p->ru_a * p->ru_x + p->ru_b) % p->ru_m;
        }
 
        p->ru_counter += i;
diff -r f92521848b88 -r b5f2eecc1929 sys/netinet6/ip6_id.c
--- a/sys/netinet6/ip6_id.c     Mon Sep 15 22:30:38 2003 +0000
+++ b/sys/netinet6/ip6_id.c     Mon Sep 15 23:38:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_id.c,v 1.7 2003/09/13 21:32:59 itojun Exp $        */
+/*     $NetBSD: ip6_id.c,v 1.8 2003/09/15 23:38:58 itojun Exp $        */
 /*     $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $  */
 /*     $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $       */
 
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.7 2003/09/13 21:32:59 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_id.c,v 1.8 2003/09/15 23:38:58 itojun Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -238,7 +238,7 @@
 
        for (i = 0; i <= n; i++) {
                /* Linear Congruential Generator */
-               p->ru_x = (p->ru_a * p->ru_x + p->ru_b) % p->ru_m;
+               p->ru_x = ((u_int64_t)p->ru_a * p->ru_x + p->ru_b) % p->ru_m;
        }
 
        p->ru_counter += i;



Home | Main Index | Thread Index | Old Index