From: Laszlo Ersek <ler...@redhat.com>

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

Suggested-by: Eric Blake <ebl...@redhat.com>
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitul...@redhat.com>
Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com>
(cherry picked from commit 2b720018060179b394f8ce736983373ab80dd37c)

Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com>
---
 qga/commands-posix.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 933c700..e439851 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -277,6 +277,9 @@ safe_open_or_create(const char *path, const char *mode, 
Error **err)
             }
 
             close(fd);
+            if (oflag & O_CREAT) {
+                unlink(path);
+            }
         }
     }
 
-- 
1.7.9.5


Reply via email to