From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6JK-0006lp-7I for qemu-devel@nongnu.org; Wed, 08 May 2013 11:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua6JH-0004cQ-HV for qemu-devel@nongnu.org; Wed, 08 May 2013 11:29:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6JH-0004cH-AW for qemu-devel@nongnu.org; Wed, 08 May 2013 11:29:39 -0400 From: Laszlo Ersek Date: Wed, 8 May 2013 17:31:36 +0200 Message-Id: <1368027096-12108-3-git-send-email-lersek@redhat.com> In-Reply-To: <1368027096-12108-1-git-send-email-lersek@redhat.com> References: <1368027096-12108-1-git-send-email-lersek@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/2] qga: unlink just created guest-file if fchmod() or fdopen() fails on it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: eblake@redhat.com, aliguori@us.ibm.com, peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org We shouldn't allow guest filesystem pollution on error paths. Suggested-by: Eric Blake Signed-off-by: Laszlo Ersek --- qga/commands-posix.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 2eec712..e199738 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); + } } } -- 1.7.1