Module Name:    src
Committed By:   christos
Date:           Sun Dec 13 18:09:00 UTC 2015

Modified Files:
        src/usr.bin/pmap: main.c

Log Message:
PR/50546: David Binderman: Fix bad sizeof


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/pmap/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/pmap/main.c
diff -u src/usr.bin/pmap/main.c:1.24 src/usr.bin/pmap/main.c:1.25
--- src/usr.bin/pmap/main.c:1.24	Tue Oct 25 19:45:19 2011
+++ src/usr.bin/pmap/main.c	Sun Dec 13 13:09:00 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $ */
+/*	$NetBSD: main.c,v 1.25 2015/12/13 18:09:00 christos Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.24 2011/10/25 23:45:19 jym Exp $");
+__RCSID("$NetBSD: main.c,v 1.25 2015/12/13 18:09:00 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -468,18 +468,19 @@ load_name_cache(kvm_t *kd)
 {
 	struct namecache _ncp, *ncp, *oncp;
 	struct nchashhead _ncpp, *ncpp; 
-	u_long nchash, i;
+	u_long lnchash;
+	size_t nchash, i;
 
 	LIST_INIT(&lcache);
 
-	_KDEREF(kd, nchash_addr, &nchash, sizeof(nchash));
-	nchashtbl = malloc(sizeof(nchashtbl) * (int)(nchash + 1));
-	_KDEREF(kd, nchashtbl_addr, nchashtbl,
-		sizeof(nchashtbl) * (int)(nchash + 1));
+	_KDEREF(kd, nchash_addr, &lnchash, sizeof(lnchash));
+	nchash = (size_t)lnchash + 1;
+	nchashtbl = malloc(nchash * sizeof(*nchashtbl));
+	_KDEREF(kd, nchashtbl_addr, nchashtbl, sizeof(*nchashtbl) * nchash);
 
 	ncpp = &_ncpp;
 
-	for (i = 0; i <= nchash; i++) {
+	for (i = 0; i < nchash; i++) {
 		ncpp = &nchashtbl[i];
 		oncp = NULL;
 		LIST_FOREACH(ncp, ncpp, nc_hash) {

Reply via email to