From patchwork Wed May 8 15:31:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 242600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7FFE92C00F2 for ; Thu, 9 May 2013 01:30:11 +1000 (EST) Received: from localhost ([::1]:45988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua6Jl-0006r2-MP for incoming@patchwork.ozlabs.org; Wed, 08 May 2013 11:30:09 -0400 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 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r48FTNHj016957 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 May 2013 11:29:23 -0400 Received: from lacos-laptop.usersys.redhat.com (vpn1-5-19.ams2.redhat.com [10.36.5.19]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r48FTIQ2000355; Wed, 8 May 2013 11:29:22 -0400 From: Laszlo Ersek To: eblake@redhat.com, aliguori@us.ibm.com, peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] qga: unlink just created guest-file if fchmod() or fdopen() fails on it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We shouldn't allow guest filesystem pollution on error paths. Suggested-by: Eric Blake Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake --- 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); + } } }