Subject: bin/595: rpc.bootparamd leaks FILE *'s.
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: None <chs@cs.cmu.edu>
List: netbsd-bugs
Date: 11/28/1994 22:50:04
>Number:         595
>Category:       bin
>Synopsis:       missing fclose() in rpc.bootparamd
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 28 22:50:02 1994
>Originator:     Chuck Silvers
>Organization:
CMU
>Release:        1.0
>Environment:
System: NetBSD chuq.fac.cs.cmu.edu 1.0 NetBSD 1.0 (SPARC) #39: Fri Nov 18 02:33:07 EST 1994 chs@chuq.fac.cs.cmu.edu:/usr/src/sys/arch/sparc/compile/SPARC sparc


>Description:

In lookup_bootparam() in usr.sbin/rpc.bootparamd/bootparamd.c,
if "id" is NULL, the function returns without fclose()ing the bootparams file.

>How-To-Repeat:

Make enough bootparam requests and eventually it should stop giving
answers.  For me, it just dumped core once it hit the fopen() bug
that I just reported before this one.

>Fix:

*** bootparamd.c.orig	Tue Nov 29 01:38:12 1994
--- /usr/src/usr.sbin/rpc.bootparamd/bootparamd.c	Mon Nov 28 00:55:10 1994
***************
*** 351,358 ****
  			strncpy(client_canonical, word, MAX_MACHINE_NAME);
  
  		/* We have found a line for CLIENT */
! 		if (id == NULL)
  			return 0;
  
  		/* Look for a value for the parameter named by ID */
  		while ((word = strsep(&bp, " \t\n")) != NULL) {
--- 351,360 ----
  			strncpy(client_canonical, word, MAX_MACHINE_NAME);
  
  		/* We have found a line for CLIENT */
! 		if (id == NULL) {
! 			fclose(f);
  			return 0;
+ 		}
  
  		/* Look for a value for the parameter named by ID */
  		while ((word = strsep(&bp, " \t\n")) != NULL) {
>Audit-Trail:
>Unformatted: