[libglnx] fdio: Delete .tmp file on failure



commit a6d08657aa868a0d5c7b5dd494e16f65415a148f
Author: Yu Qi Zhang <jzehrarnyg gmail com>
Date:   Thu Jun 16 15:39:32 2016 +0000

    fdio: Delete .tmp file on failure
    
    We noticed the temp files being left over in ostree when (mistakenly)
    trying to replace the contents of a subpath that wasn't a directory.
    
    In the future we should look at the systemd code using `O_TMPFILE`
    here.

 glnx-fdio.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/glnx-fdio.c b/glnx-fdio.c
index 62371d0..cdbb69f 100644
--- a/glnx-fdio.c
+++ b/glnx-fdio.c
@@ -746,6 +746,8 @@ glnx_file_replace_contents_with_perms_at (int                   dfd,
 
   ret = TRUE;
  out:
+  if (!ret)
+    (void) unlink (tmppath);
   return ret;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]