Patchwork [2/2] qga: try to unlink just created guest-file if fchmod() fails on it

login
register
mail settings
Submitter Laszlo Ersek
Date May 7, 2013, 4:56 p.m.
Message ID <1367945808-19979-2-git-send-email-lersek@redhat.com>
Download mbox | patch
Permalink /patch/242416/
State New
Headers show

Comments

Laszlo Ersek - May 7, 2013, 4:56 p.m.
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 |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 2eec712..d301b1f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -341,6 +341,7 @@  safe_open_or_create(const char *path, const char *mode, Error **err)
                 error_setg_errno(&local_err, errno, "failed to set permission "
                                  "0%03o on new file '%s' (mode: '%s')",
                                  (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+                unlink(path);
             } else {
                 FILE *f;