From 2b720018060179b394f8ce736983373ab80dd37c Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 8 May 2013 17:31:36 +0200 Subject: [PATCH] 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 Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino Signed-off-by: Michael Roth --- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 2eec71252..e199738c7 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); + } } } -- 2.39.2