Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/net correct malloc() size computation mistake. bug...



details:   https://anonhg.NetBSD.org/src/rev/241ed5b6f90a
branches:  trunk
changeset: 495226:241ed5b6f90a
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jul 24 12:06:55 2000 +0000

description:
correct malloc() size computation mistake.  bug from bsdi, found
by kjc.  sync with kame.

diffstat:

 lib/libc/net/if_nameindex.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (35 lines):

diff -r 9167d0c2531a -r 241ed5b6f90a lib/libc/net/if_nameindex.c
--- a/lib/libc/net/if_nameindex.c       Mon Jul 24 11:59:38 2000 +0000
+++ b/lib/libc/net/if_nameindex.c       Mon Jul 24 12:06:55 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: if_nameindex.c,v 1.3 2000/07/06 02:55:45 christos Exp $        */
-/*     $KAME: if_nameindex.c,v 1.3 2000/04/24 10:08:41 itojun Exp $    */
+/*     $NetBSD: if_nameindex.c,v 1.4 2000/07/24 12:06:55 itojun Exp $  */
+/*     $KAME: if_nameindex.c,v 1.5 2000/07/24 12:03:31 itojun Exp $    */
 
 /*-
  * Copyright (c) 1997, 2000
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: if_nameindex.c,v 1.3 2000/07/06 02:55:45 christos Exp $");
+__RCSID("$NetBSD: if_nameindex.c,v 1.4 2000/07/24 12:06:55 itojun Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -113,11 +113,11 @@
         * for the array of structures, and the last part for
         * the strings.
         */
-       cp = malloc(ni*(sizeof(struct if_nameindex) + 1) + nbytes);
-       ifni = (struct if_nameindex *)(void *)cp;
+       cp = malloc((ni + 1) * sizeof(struct if_nameindex) + nbytes);
+       ifni = (struct if_nameindex *)cp;
        if (ifni == NULL)
                goto out;
-       cp += ni*(sizeof(struct if_nameindex) + 1);
+       cp += (ni + 1) * sizeof(struct if_nameindex);
 
        /*
         * Now just loop through the list of interfaces again,



Home | Main Index | Thread Index | Old Index