From: Laszlo Ersek Date: Wed, 8 May 2013 15:31:36 +0000 (+0200) Subject: qga: unlink just created guest-file if fchmod() or fdopen() fails on it X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~900^2~59^2~66^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b720018060179b394f8ce736983373ab80dd37c;p=sdk%2Femulator%2Fqemu.git 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 --- 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); + } } }