From stefan@fafoe.dyndns.org  Thu Jul  4 04:39:09 2002
Return-Path: <stefan@fafoe.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 1F12737B400; Thu,  4 Jul 2002 04:39:09 -0700 (PDT)
Received: from fafoe.dyndns.org (chello212186121237.14.vie.surfer.at [212.186.121.237])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 8BF1143E42; Thu,  4 Jul 2002 04:39:08 -0700 (PDT)
	(envelope-from stefan@fafoe.dyndns.org)
Received: by frog.fafoe (Postfix, from userid 1001)
	id 57E60245; Thu,  4 Jul 2002 13:41:50 +0200 (CEST)
Message-Id: <20020704114150.GB254@frog.fafoe>
Date: Thu, 4 Jul 2002 13:41:50 +0200
From: Stefan Farfeleder <e0026813@stud3.tuwien.ac.at>
To: Eugene Grosbein <eu@grosbein.pp.ru>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, stable@FreeBSD.ORG
In-Reply-To: <20020704112411.GA254@frog.fafoe>
Subject: Re: /bin/sh with builtin 'test' has memory leaks
References: <200207041016.g64AGhEF017182@grosbein.pp.ru> <20020704112411.GA254@frog.fafoe>

>Number:         40181
>Category:       bin
>Synopsis:       Re: /bin/sh with builtin 'test' has memory leaks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 04 04:40:03 PDT 2002
>Closed-Date:    Wed Jul 10 17:32:51 PDT 2002
>Last-Modified:  Wed Jul 10 17:32:51 PDT 2002
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 --RASg3xLB4tUQ4RcS
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Thu, Jul 04, 2002 at 01:24:11PM +0200, Stefan Farfeleder wrote:
 > On Thu, Jul 04, 2002 at 06:16:43PM +0800, Eugene Grosbein wrote:
 > > 
 > > >Description:
 > > 	There seem to be memory leak in 'test' command that was not
 > > 	a problem when it was external command but it became a problem
 > > 	when 'test' was made builtin.
 > 
 
 Sorry, here's the real patch.
 
 --RASg3xLB4tUQ4RcS
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="test.patch"
 
 Index: src/bin/test/test.c
 ===================================================================
 RCS file: /home/ncvs/src/bin/test/test.c,v
 retrieving revision 1.29.2.5
 diff -u -r1.29.2.5 test.c
 --- src/bin/test/test.c	29 Apr 2002 13:06:02 -0000	1.29.2.5
 +++ src/bin/test/test.c	4 Jul 2002 11:37:30 -0000
 @@ -28,6 +28,8 @@
  #include <string.h>
  #include <unistd.h>
  
 +char **nargv;
 +
  #ifdef SHELL
  #define main testcmd
  #include "bltin/bltin.h"
 @@ -51,6 +53,7 @@
  #else
  	va_start(ap, msg);
  #endif
 +	free(nargv);
  	verrx(2, msg, ap);
  	/*NOTREACHED*/
  	va_end(ap);
 @@ -199,7 +202,6 @@
  	uid_t	euid, uid;
  	int	i, res;
  	char	*p;
 -	char	**nargv;
  
  	/*
  	 * XXX copy the whole contents of argv to a newly allocated
 @@ -240,6 +242,8 @@
  		syntax(*t_wp, "unexpected operator");
  	(void)setregid(gid, egid);
  	(void)setreuid(uid, euid);
 +
 +	free(nargv);
  
  	return res;
  }
 
 --RASg3xLB4tUQ4RcS--
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Wed Jul 10 17:31:24 PDT 2002 
State-Changed-Why:  
Followup to bin/40177 misfiled as a new PR. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Wed Jul 10 17:31:24 PDT 2002 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=40180 
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Wed Jul 10 17:31:24 PDT 2002 
State-Changed-Why:  
Followup to bin/40177 misfiled as a new PR. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Wed Jul 10 17:31:24 PDT 2002 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=40181 
>Unformatted:
