]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(change_file_owner): Don't leak file descriptors when dereferencing symlinks.
authorJim Meyering <jim@meyering.net>
Thu, 10 Jul 2003 10:59:47 +0000 (10:59 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 10 Jul 2003 10:59:47 +0000 (10:59 +0000)
src/chown-core.c

index b38efaa895d4d4ff1191c840599998b791cd572d..a46dd7ef77061b4f2a2177f2baf6b188ceee888b 100644 (file)
@@ -1,5 +1,5 @@
 /* chown-core.c -- core functions for changing ownership.
-   Copyright (C) 2000, 2002 Free Software Foundation.
+   Copyright (C) 2000, 2002, 2003 Free Software Foundation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -295,6 +295,8 @@ change_file_owner (int cmdline_arg, const char *file, uid_t uid, gid_t gid,
                     file and use fchown on the resulting descriptor.  */
                  int fd = open (file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
                  fail = (fd == -1 ? 1 : fchown (fd, new_uid, new_gid));
+                 if (fd != -1)
+                   close (fd);
                }
              else
                {