From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9FdW-0004kn-V3 for qemu-devel@nongnu.org; Wed, 05 Sep 2012 09:27:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9FdR-0003HM-77 for qemu-devel@nongnu.org; Wed, 05 Sep 2012 09:27:18 -0400 From: riegamaths@gmail.com Date: Wed, 5 Sep 2012 21:26:22 +0800 Message-Id: <1346851582-9296-1-git-send-email-riegamaths@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] =?utf-8?q?=5BPATCH=5D_block=3A_Don=27t_forget_to_del?= =?utf-8?q?ete_temporary_file?= List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: qemu-trivial , Dunrong Huang From: Dunrong Huang The caller would not delete temporary file after failed get_tmp_filename(). Signed-off-by: Dunrong Huang --- block.c | 6 +++++- 1 个文件被修改,插入 5 行(+),删除 1 行(-) diff --git a/block.c b/block.c index 074987e..2bc9f75 100644 --- a/block.c +++ b/block.c @@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size) return -EOVERFLOW; } fd = mkstemp(filename); - if (fd < 0 || close(fd)) { + if (fd < 0) { + return -errno; + } + if (close(fd) != 0) { + unlink(filename); return -errno; } return 0; -- 1.7.12