fwcontrol -r missing a close() call

From: Andre Guibert de Bruet <andy_at_siliconlandmark.com>
Date: Tue, 19 Aug 2003 11:21:59 -0400 (EDT)
# 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
_at__at_ -527,5 +527,9 _at__at_
                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/    >
Received on Tue Aug 19 2003 - 06:22:00 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:19 UTC