From owner-freebsd-bugs Thu May 25 13:40: 8 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id E06A137B528 for ; Thu, 25 May 2000 13:40:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id NAA20922; Thu, 25 May 2000 13:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7]) by hub.freebsd.org (Postfix) with ESMTP id E6CA937B690 for ; Thu, 25 May 2000 13:34:08 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from archie@localhost) by bubba.whistle.com (8.9.3/8.9.2) id NAA09637; Thu, 25 May 2000 13:34:09 -0700 (PDT) Message-Id: <200005252034.NAA09637@bubba.whistle.com> Date: Thu, 25 May 2000 13:34:09 -0700 (PDT) From: Archie Cobbs Reply-To: archie@whistle.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/18817: possible file descriptor leak in dhclient(8) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 18817 >Category: bin >Synopsis: possible file descriptor leak in dhclient(8) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 25 13:40:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Archie Cobbs >Release: FreeBSD 3.4-RELEASE i386 >Organization: Whistle Communications, Inc. >Environment: 3.4-RELEASE >Description: It appears that the function read_client_leases() in dhclient(8) clparse.c contains a file descriptor leak. The FILE *cfile is never fclose()'d. Also, when the dhclient-script is exec'd, we don't want any open file descriptors in the dhclient(8) process to be inherited by the child process (i.e., the script). So dhclient should be doing an ``fcntl(fileno(fp), F_SETFD, 1)'' for every FILE* it opens that can possibly still be open when the script is executed (e.g, the lease file). >How-To-Repeat: Was determined by inspection; this could all be wrong. >Fix: Index: clparse.c =================================================================== RCS file: /cvs/freebsd/src/contrib/isc-dhcp/client/clparse.c,v retrieving revision 1.3.2.2 diff -u -u -r1.3.2.2 clparse.c --- clparse.c 1999/05/08 18:05:07 1.3.2.2 +++ clparse.c 2000/05/25 20:34:16 @@ -170,6 +170,8 @@ parse_client_lease_statement (cfile, 0); } while (1); + + fclose (cfile); } /* client-declaration :== >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message