[Top][All Lists]

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

file descriptor leak when cp --preserve=context fails

From: Paul Eggert
Subject: file descriptor leak when cp --preserve=context fails
Date: Wed, 28 Nov 2007 15:42:37 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

I found this by code inspection.  The fix is obvious, though I don't
have a SELinux platform to test the fix on.

2007-11-28  Paul Eggert  <address@hidden>

        Close a file descriptor leak when cp --preserve=context fails.
        * src/copy.c (copy_reg): Close dest_desc too, if getfscreatecon
        or fsetfilecon fail.

diff --git a/src/copy.c b/src/copy.c
index 03bfa40..1e803ec 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -376,7 +376,7 @@ copy_reg (char const *src_name, char const *dst_name,
              if (x->require_preserve_context)
                  return_val = false;
-                 goto close_src_desc;
+                 goto close_src_and_dst_desc;

@@ -391,7 +391,7 @@ copy_reg (char const *src_name, char const *dst_name,
                      return_val = false;
                      freecon (con);
-                     goto close_src_desc;
+                     goto close_src_and_dst_desc;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]