From owner-freebsd-current@FreeBSD.ORG Tue Aug 19 08:22:00 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D19C216A4BF for ; Tue, 19 Aug 2003 08:22:00 -0700 (PDT) Received: from alpha.siliconlandmark.com (alpha.siliconlandmark.com [209.69.98.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0297843F3F for ; Tue, 19 Aug 2003 08:22:00 -0700 (PDT) (envelope-from andy@siliconlandmark.com) Received: from alpha.siliconlandmark.com (localhost [127.0.0.1]) h7JFLx3E002070 for ; Tue, 19 Aug 2003 11:21:59 -0400 (EDT) (envelope-from andy@siliconlandmark.com) Received: from localhost (andy@localhost)h7JFLx0s002067 for ; Tue, 19 Aug 2003 11:21:59 -0400 (EDT) (envelope-from andy@siliconlandmark.com) X-Authentication-Warning: alpha.siliconlandmark.com: andy owned process doing -bs Date: Tue, 19 Aug 2003 11:21:59 -0400 (EDT) From: Andre Guibert de Bruet To: current@freebsd.org Message-ID: <20030819110750.Q452@alpha.siliconlandmark.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: fwcontrol -r missing a close() call X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2003 15:22:01 -0000 # truss fwcontrol -r mmap(0x0,3440,0x3,0x1000,-1,0x0) = 671535104 (0x2806d000) munmap(0x2806d000,0xd70) = 0 (0x0) __sysctl(0xbfbffa28,0x2,0x2806adac,0xbfbffa24,0x0,0x0) = 0 (0x0) mmap(0x0,32768,0x3,0x1002,-1,0x0) = 671535104 (0x2806d000) issetugid() = 0 (0x0) open("/var/run/ld-elf.so.hints",0x0,00) = 3 (0x3) read(0x3,0xbfbffac0,0x80) = 128 (0x80) lseek(3,0x80,0) = 128 (0x80) read(0x3,0x28071000,0x7a) = 122 (0x7a) close(3) = 0 (0x0) access("/usr/lib/libc.so.5",0) = 0 (0x0) open("/usr/lib/libc.so.5",0x0,027757775430) = 3 (0x3) fstat(3,0xbfbffb00) = 0 (0x0) read(0x3,0x28069d00,0x1000) = 4096 (0x1000) mmap(0x0,880640,0x5,0x20002,3,0x0) = 671567872 (0x28075000) mprotect(0x28134000,0x1000,0x7) = 0 (0x0) mprotect(0x28134000,0x1000,0x5) = 0 (0x0) mmap(0x28135000,20480,0x3,0x12,3,0xbf000) = 672354304 (0x28135000) mmap(0x2813a000,73728,0x3,0x1012,-1,0x0) = 672374784 (0x2813a000) close(3) = 0 (0x0) mmap(0x0,360,0x3,0x1000,-1,0x0) = 672448512 (0x2814c000) munmap(0x2814c000,0x168) = 0 (0x0) mprotect(0x28075000,0xc0000,0x7) = 0 (0x0) mmap(0x0,21240,0x3,0x1000,-1,0x0) = 672448512 (0x2814c000) munmap(0x2814c000,0x52f8) = 0 (0x0) mprotect(0x28075000,0xc0000,0x5) = 0 (0x0) sigaction(SIGILL,0xbfbffb40,0xbfbffb20) = 0 (0x0) sigprocmask(0x1,0x0,0x28069c5c) = 0 (0x0) sigaction(SIGILL,0xbfbffb20,0x0) = 0 (0x0) sigprocmask(0x1,0x28069c00,0xbfbffb50) = 0 (0x0) sigprocmask(0x3,0x28069c10,0x0) = 0 (0x0) open("/dev/fw0.0",0x2,01001132500) = 3 (0x3) ioctl(3,FW_IBUSRST,0xbfbff400) = 0 (0x0) exit(0x0) process exit, rval = 0 We're not closing fd #3 before exiting the process. This is also the case with 4.8-STABLE. Digging into the code it appears that it would be trivial to add two lines to catch all instances of this (copy and pasted): --- fwcontrol.c.orig Mon Aug 4 23:26:14 2003 +++ fwcontrol.c Tue Aug 19 11:15:13 2003 @@ -527,5 +527,9 @@ default: usage(); } + + if(fd != -1) + close(fd); + return 0; } Semantics? Nit-picking? Both? :) Regards, > Andre Guibert de Bruet | Enterprise Software Consultant > > Silicon Landmark, LLC. | http://siliconlandmark.com/ >