qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: eblake@redhat.com, aliguori@us.ibm.com, peter.maydell@linaro.org,
	mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 2/2] qga: unlink just created guest-file if fchmod() or fdopen() fails on it
Date: Wed,  8 May 2013 17:31:36 +0200	[thread overview]
Message-ID: <1368027096-12108-3-git-send-email-lersek@redhat.com> (raw)
In-Reply-To: <1368027096-12108-1-git-send-email-lersek@redhat.com>

We shouldn't allow guest filesystem pollution on error paths.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 qga/commands-posix.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 2eec712..e199738 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -355,6 +355,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err)
             }
 
             close(fd);
+            if (oflag & O_CREAT) {
+                unlink(path);
+            }
         }
     }
 
-- 
1.7.1

  parent reply	other threads:[~2013-05-08 15:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-08 15:31 [Qemu-devel] [PATCH v2 0/2] qga umask fix addenda Laszlo Ersek
2013-05-08 15:31 ` [Qemu-devel] [PATCH v2 1/2] qga: distinguish binary modes in "guest_file_open_modes" map Laszlo Ersek
2013-05-08 15:31 ` Laszlo Ersek [this message]
2013-05-08 17:07   ` [Qemu-devel] [PATCH v2 2/2] qga: unlink just created guest-file if fchmod() or fdopen() fails on it Eric Blake
2013-05-10 13:29 ` [Qemu-devel] [PATCH v2 0/2] qga umask fix addenda Luiz Capitulino
2013-05-10 19:30 ` mdroth
2013-05-10 19:53   ` Laszlo Ersek
2013-05-10 20:09     ` mdroth
2013-05-12 16:47       ` Andreas Färber
2013-05-13 11:33         ` mdroth

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=1368027096-12108-3-git-send-email-lersek@redhat.com \
    --to=lersek@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=eblake@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --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).