NetBSD Problem Report #50546
From www@NetBSD.org Sun Dec 13 16:54:29 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 6DAAD7ABFE
for <gnats-bugs@gnats.NetBSD.org>; Sun, 13 Dec 2015 16:54:29 +0000 (UTC)
Message-Id: <20151213165428.7B8DE7ACB2@mollari.NetBSD.org>
Date: Sun, 13 Dec 2015 16:54:28 +0000 (UTC)
From: dcb314@hotmail.com
Reply-To: dcb314@hotmail.com
To: gnats-bugs@NetBSD.org
Subject: src/usr.bin/pmap/main.c:476: possible bad size in malloc ?
X-Send-Pr-Version: www-1.0
>Number: 50546
>Category: bin
>Synopsis: src/usr.bin/pmap/main.c:476: possible bad size in malloc ?
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Dec 13 16:55:00 +0000 2015
>Closed-Date: Sun Dec 13 20:29:24 +0000 2015
>Last-Modified: Mon Dec 14 02:50:00 +0000 2015
>Originator: David Binderman
>Release: cvs dated 20151210
>Organization:
>Environment:
>Description:
[src/usr.bin/pmap/main.c:476]: (warning) Size of pointer 'nchashtbl' used instead of size of its data.
Source code is
nchashtbl = malloc(sizeof(nchashtbl) * (int)(nchash + 1));
Maybe better code
nchashtbl = malloc(sizeof(*nchashtbl) * (int)(nchash + 1));
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50546 CVS commit: src/usr.bin/pmap
Date: Sun, 13 Dec 2015 13:09:01 -0500
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.
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sun, 13 Dec 2015 20:29:24 +0000
State-Changed-Why:
christos fixed it.
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
Date: Mon, 14 Dec 2015 00:46:47 +0100
On Sun, Dec 13, 2015 at 06:10:01PM +0000, Christos Zoulas wrote:
> The following reply was made to PR bin/50546; it has been noted by GNATS.
>
> From: "Christos Zoulas" <christos@netbsd.org>
> To: gnats-bugs@gnats.NetBSD.org
> Cc:
> Subject: PR/50546 CVS commit: src/usr.bin/pmap
> Date: Sun, 13 Dec 2015 13:09:01 -0500
>
> 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
Please use calloc.
Joerg
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
dcb314@hotmail.com
Cc:
Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
Date: Sun, 13 Dec 2015 19:08:24 -0500
On Dec 13, 11:50pm, joerg@britannica.bec.de (Joerg Sonnenberger) wrote:
-- Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
| Please use calloc.
I had it and reverted it, because it does not help since it does the multiply
immediately to load the data so zeroing is just a waste.
christos
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, dcb314@hotmail.com
Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
Date: Mon, 14 Dec 2015 03:46:02 +0100
On Mon, Dec 14, 2015 at 12:10:00AM +0000, Christos Zoulas wrote:
> The following reply was made to PR bin/50546; it has been noted by GNATS.
>
> From: christos@zoulas.com (Christos Zoulas)
> To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
> dcb314@hotmail.com
> Cc:
> Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
> Date: Sun, 13 Dec 2015 19:08:24 -0500
>
> On Dec 13, 11:50pm, joerg@britannica.bec.de (Joerg Sonnenberger) wrote:
> -- Subject: Re: PR/50546 CVS commit: src/usr.bin/pmap
>
> | Please use calloc.
>
> I had it and reverted it, because it does not help since it does the multiply
> immediately to load the data so zeroing is just a waste.
It still ensures the overflow protection. For any non-trivial size, the
zeroing is likely already done by the kernel anyway.
Joerg
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.