]> git.proxmox.com Git - qemu.git/commitdiff
qga: unlink just created guest-file if fchmod() or fdopen() fails on it
authorLaszlo Ersek <lersek@redhat.com>
Wed, 8 May 2013 15:31:36 +0000 (17:31 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 14 May 2013 21:18:25 +0000 (16:18 -0500)
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>
(cherry picked from commit 2b720018060179b394f8ce736983373ab80dd37c)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-posix.c

index 933c700edbf3c8a99b1508cde6bbc484ddb5357f..e439851748aa88aed8984e94d0968c1189bc9fa4 100644 (file)
@@ -277,6 +277,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err)
             }
 
             close(fd);
+            if (oflag & O_CREAT) {
+                unlink(path);
+            }
         }
     }