Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Large values of sb_max would cause an overflow in s...



details:   https://anonhg.NetBSD.org/src/rev/91788347001a
branches:  trunk
changeset: 509238:91788347001a
user:      kml <kml%NetBSD.org@localhost>
date:      Mon Apr 30 03:32:56 2001 +0000

description:
Large values of sb_max would cause an overflow in sbreserve();  cast to
u_quad_t to avoid this.  (from FreeBSD uipc_socket2.c v1.19)

diffstat:

 sys/kern/uipc_socket2.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (19 lines):

diff -r 5c0e7d455ae5 -r 91788347001a sys/kern/uipc_socket2.c
--- a/sys/kern/uipc_socket2.c   Mon Apr 30 03:30:45 2001 +0000
+++ b/sys/kern/uipc_socket2.c   Mon Apr 30 03:32:56 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket2.c,v 1.37 2001/02/27 05:19:15 lukem Exp $  */
+/*     $NetBSD: uipc_socket2.c,v 1.38 2001/04/30 03:32:56 kml Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -375,7 +375,8 @@
 sbreserve(struct sockbuf *sb, u_long cc)
 {
 
-       if (cc == 0 || cc > sb_max * MCLBYTES / (MSIZE + MCLBYTES))
+       if (cc == 0 || 
+           (u_quad_t) cc > (u_quad_t) sb_max * MCLBYTES / (MSIZE + MCLBYTES))
                return (0);
        sb->sb_hiwat = cc;
        sb->sb_mbmax = min(cc * 2, sb_max);



Home | Main Index | Thread Index | Old Index