File descriptor leak in libcam

Joe Marcus Clarke marcus at FreeBSD.org
Sun Apr 30 00:08:47 UTC 2006


On Sat, 2006-04-29 at 17:47 -0600, Scott Long wrote:
> Joe Marcus Clarke wrote:
> > There is a leak in the cam_lookup_pass() if the ioctl call fails to find
> > the passthru device.  Basically, the xpt file descriptor will not be
> > closed.  Can anyone give me permission to commit the following patch?
> > Thanks.
> > 
> > http://www.marcuscom.com/downloads/camlib.c.diff
> > 
> > Joe
> > 
> 
> Looks good to me.  Style-wise, I'd have it close the fd before
> testing the return of the ioctl, but that's minor.

So you'd rather see something like:

int rc;
...

rc = ioctl(fd, CAMGETPASSTHRU, &ccb);
close(fd);

if (rc == -1) {
...

Joe

-- 
Joe Marcus Clarke
FreeBSD GNOME Team      ::      gnome at FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20060430/9ba47ecb/attachment.pgp


More information about the freebsd-current mailing list