Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jul 1999 14:13:03 +1000
From:      Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/12769: Memory leak in init(8)
Message-ID:  <99Jul23.135448est.40354@border.alcanet.com.au>

next in thread | raw e-mail | index | archive | help

>Number:         12769
>Category:       bin
>Synopsis:       Memory leak in init(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 22 21:20:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Peter Jeremy
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Alcatel Australia Limited
>Environment:

	cvs-cur 5500

>Description:

	If init is unable to parse the getty or window command line, it
	doesn't free the memory it allocated to contain the argv pointers
	(allocated at 1 more than half the length of the command line).

>How-To-Repeat:

	Found by code inspection.

	An /etc/ttys containing the following line:
tty99 "                                                              " cons25 on secure
	should leak 128 bytes on every SIGHUP.  Enough similar lines and
	enough SIGHUPs show a detectable increase in process size.

>Fix:

Index: sbin/init/init.c
===================================================================
RCS file: /home/CVSROOT/./src/sbin/init/init.c,v
retrieving revision 1.33
diff -u -r1.33 init.c
--- init.c	1999/06/18 09:08:09	1.33
+++ init.c	1999/07/23 03:53:39
@@ -935,8 +935,10 @@
 	register char **argv = (char **) malloc(((strlen(command) + 1) / 2 + 1)
 						* sizeof (char *));
 
-	if ((argv[argc++] = strk(command)) == 0)
-		return 0;
+	if ((argv[argc++] = strk(command)) == 0) {
+		free(argv);
+		return (NULL);
+	}
 	while ((argv[argc++] = strk((char *) 0)) != NULL)
 		continue;
 	return argv;
@@ -1044,7 +1046,7 @@
 		return (0);
 	}
 	if (sp->se_window) {
-			free(sp->se_window);
+		free(sp->se_window);
 		free(sp->se_window_argv_space);
 		free(sp->se_window_argv);
 	}

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99Jul23.135448est.40354>