qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Don't forget to delete temporary file
@ 2012-09-05 13:26 riegamaths
  2012-09-05 15:40 ` Paolo Bonzini
  2012-09-11 10:23 ` Kevin Wolf
  0 siblings, 2 replies; 9+ messages in thread
From: riegamaths @ 2012-09-05 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Dunrong Huang

From: Dunrong Huang <riegamaths@gmail.com>

The caller would not delete temporary file after failed get_tmp_filename().

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-09-14  7:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 13:26 [Qemu-devel] [PATCH] block: Don't forget to delete temporary file riegamaths
2012-09-05 15:40 ` Paolo Bonzini
2012-09-05 15:51   ` Dunrong Huang
2012-09-05 16:02   ` Markus Armbruster
2012-09-05 16:23     ` Paolo Bonzini
2012-09-05 16:28       ` Eric Blake
2012-09-06  3:47         ` Dunrong Huang
2012-09-11 10:23 ` Kevin Wolf
2012-09-14  7:45   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).