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  <[EMAIL PROTECTED]>

        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;
                    }
                }
              freecon(con);


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to