[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH] [UPDATED] Add host_device support to qemu-img.
From: |
Nolan |
Subject: |
[Qemu-devel] Re: [PATCH] [UPDATED] Add host_device support to qemu-img. |
Date: |
Thu, 2 Apr 2009 03:18:20 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
malc <av1474 <at> comtv.ru> writes:
> On Wed, 1 Apr 2009, Nolan wrote:
<... snip ...>
> > + fd = open(filename, O_WRONLY | O_BINARY);
> > + if (fd < 0)
> > + return -EIO;
> > +
> > + if (fstat(fd, &stat_buf) < 0)
> > + ret = -EIO;
> > + else if (!S_ISBLK(stat_buf.st_mode))
> > + ret = -EIO;
> > + else if (lseek(fd, 0, SEEK_END) < total_size * 512)
> > + ret = -ENOSPC;
>
> This leaks fescriptors doesn't it, even if only user is qemu-img which
> just exits on errors this still looks fragile.
I don't see how.
Once a valid fd is allocated, all paths out of this function pass through the
close (now below this comment) right before the "return ret;".
> > +
> > + close(fd);
> > + return ret;
> > +}
<... snip ...>