NetBSD Problem Report #50291

From itohy@netbsd.org  Tue Sep 29 13:13:18 2015
Return-Path: <itohy@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(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 B9B97A5674
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 29 Sep 2015 13:13:18 +0000 (UTC)
Message-Id: <20150929131314.F07D121C38@p655505.mie-ff01.ap.so-net.ne.jp>
Date: Tue, 29 Sep 2015 22:13:14 +0900 (JST)
From: itohy@netbsd.org
Reply-To: itohy@netbsd.org
To: gnats-bugs@gnats.NetBSD.org
Subject: usbhidaction(1) leaks memory on re-reading the config file
X-Send-Pr-Version: 3.95

>Number:         50291
>Category:       bin
>Synopsis:       usbhidaction(1) leaks memory on re-reading the config file
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    christos
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 29 13:15:00 +0000 2015
>Closed-Date:    Wed Sep 30 15:23:04 +0000 2015
>Last-Modified:  Wed Sep 30 15:25:00 +0000 2015
>Originator:     ITOH Yasufumi
>Release:        NetBSD 5.1_RC4
>Organization:
>Environment:
System: NetBSD mei.my.domain 5.1_RC4 NetBSD 5.1_RC4 (MEI) #20: Thu Dec 5 21:05:24 JST 2013 itohy@mei.my.domain:/usr/src/sys/arch/i386/compile/MEI i386
Architecture: i386
Machine: i386
>Description:
	usbhidaction(1) leaks strdup()ed memory in the command structure
	when re-reading the config file.

>How-To-Repeat:
	Found by a brain.

>Fix:
	Here's an untested patch to rev 1.25.

diff -up usbhidaction.c.orig usbhidaction.c
--- usbhidaction.c.orig	2015-09-27 22:25:24.000000000 +0900
+++ usbhidaction.c	2015-09-27 22:27:16.000000000 +0900
@@ -450,6 +450,8 @@ freecommands(struct command *cmd)
 	struct command *next;

 	while (cmd) {
+		free(cmd->name);
+		free(cmd->action);
 		next = cmd->next;
 		free(cmd);
 		cmd = next;

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50291 CVS commit: src/usr.bin/usbhidaction
Date: Tue, 29 Sep 2015 10:27:00 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Sep 29 14:27:00 UTC 2015

 Modified Files:
 	src/usr.bin/usbhidaction: usbhidaction.c

 Log Message:
 - PR/50291: Fix memory leak
 - estrdup/emalloc
 - use EXIT_FAILURE instead of 1


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

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

Responsible-Changed-From-To: bin-bug-people->christos
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Tue, 29 Sep 2015 23:25:39 +0000
Responsible-Changed-Why:
Christos committed a fix.


State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 29 Sep 2015 23:25:39 +0000
State-Changed-Why:
Fixed?


State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Wed, 30 Sep 2015 15:23:04 +0000
State-Changed-Why:
Confirmed fixed, thanks.


From: itohy@netbsd.org (ITOH Yasufumi)
To: gnats-bugs@NetBSD.org
Cc: christos@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	wiz@NetBSD.org
Subject: Re: bin/50291 (usbhidaction(1) leaks memory on re-reading the config file)
Date: Wed, 30 Sep 2015 23:03:05 +0900

 In article <20150929232539.40EA9A6554@mollari.NetBSD.org>
 wiz@NetBSD.org writes:

 > Synopsis: usbhidaction(1) leaks memory on re-reading the config file
 > 
 > Responsible-Changed-From-To: bin-bug-people->christos
 > Responsible-Changed-By: wiz@NetBSD.org
 > Responsible-Changed-When: Tue, 29 Sep 2015 23:25:39 +0000
 > Responsible-Changed-Why:
 > Christos committed a fix.
 > 
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: wiz@NetBSD.org
 > State-Changed-When: Tue, 29 Sep 2015 23:25:39 +0000
 > State-Changed-Why:
 > Fixed?

 Looks OK.
 Thanks,

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.