summaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2013-05-08 17:31:36 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2013-05-13 09:45:49 -0500
commit2b720018060179b394f8ce736983373ab80dd37c (patch)
treea04a2bf21b4289a6d6945223663e073eb49e572d /qga
parent8fe6bbca7176c9dfb35083a71bda95c1856e2ed5 (diff)
downloadqemu-2b720018060179b394f8ce736983373ab80dd37c.tar.gz
qemu-2b720018060179b394f8ce736983373ab80dd37c.tar.bz2
qemu-2b720018060179b394f8ce736983373ab80dd37c.zip
qga: unlink just created guest-file if fchmod() or fdopen() fails on it
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> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-posix.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 2eec712526..e199738c71 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);
+ }
}
}