From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>,
Wang Rui <moon.wangrui@huawei.com>
Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege()
Date: Tue, 20 May 2014 14:46:38 -0500 [thread overview]
Message-ID: <20140520194638.2719.45727@loki> (raw)
In-Reply-To: <20140520151742.6343af19@redhat.com>
Quoting Luiz Capitulino (2014-05-20 14:17:42)
> On Mon, 19 May 2014 15:26:03 +0800
> <arei.gonglei@huawei.com> wrote:
>
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > token should be closed in all conditions.
> > So move CloseHandle(token) to "out" branch.
>
> Looks good to me. Michael, are you going to pick this one?
Sure I'll queue it. Though i'm a bit surprised OpenProcessToken() will still
return an open handle on failure. Is there any confirmation a handle is
actually getting leaked here, as opposed to just returning a handle that's
already been closed?
If it's the latter case we might end up closing it twice after the change,
so just want to confirm.
>
> >
> > Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> > qga/commands-win32.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> > index d793dd0..e769396 100644
> > --- a/qga/commands-win32.c
> > +++ b/qga/commands-win32.c
> > @@ -31,7 +31,7 @@
> >
> > static void acquire_privilege(const char *name, Error **errp)
> > {
> > - HANDLE token;
> > + HANDLE token = NULL;
> > TOKEN_PRIVILEGES priv;
> > Error *local_err = NULL;
> >
> > @@ -53,13 +53,15 @@ static void acquire_privilege(const char *name, Error **errp)
> > goto out;
> > }
> >
> > - CloseHandle(token);
> > } else {
> > error_set(&local_err, QERR_QGA_COMMAND_FAILED,
> > "failed to open privilege token");
> > }
> >
> > out:
> > + if (token) {
> > + CloseHandle(token);
> > + }
> > if (local_err) {
> > error_propagate(errp, local_err);
> > }
next prev parent reply other threads:[~2014-05-20 19:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 7:26 [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege() arei.gonglei
2014-05-19 15:04 ` Eric Blake
2014-05-20 12:24 ` Yan Vugenfirer
2014-05-20 19:17 ` Luiz Capitulino
2014-05-20 19:46 ` Michael Roth [this message]
2014-05-21 9:00 ` Yan Vugenfirer
2014-05-21 10:11 ` Wangrui (K)
-- strict thread matches above, loose matches on Subject: below --
2014-06-05 19:41 [Qemu-devel] [PULL 0/1] qemu-ga fixes for win32 Michael Roth
2014-06-05 19:41 ` [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege() Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140520194638.2719.45727@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=moon.wangrui@huawei.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).