tag 563726 + patch
thanks

This patch makes sure that futimens is only called with a valid file
descriptor. It may looks a lot of changes, but they are only due to
indentation. The only added line is the "if (fd >= 0)", which makes sure
that futimens() is not called with AT_FDCWD as the first argument. In
that case POSIX 2008 mandates that -1 is returned with errno set to
EBADF.

--- coreutils-8.1.orig/lib/utimens.c
+++ coreutils-8.1/lib/utimens.c
@@ -226,19 +226,20 @@
         }
 # endif /* HAVE_UTIMENSAT */
 # if HAVE_FUTIMENS
-      {
-        int result = futimens (fd, ts);
+      if (fd >= 0)
+        {
+          int result = futimens (fd, ts);
 #  ifdef __linux__
-        /* Work around the same bug as above.  */
-        if (0 < result)
-          errno = ENOSYS;
+          /* Work around the same bug as above.  */
+          if (0 < result)
+            errno = ENOSYS;
 #  endif /* __linux__ */
-        if (result == 0 || errno != ENOSYS)
-          {
-            utimensat_works_really = 1;
-            return result;
-          }
-      }
+          if (result == 0 || errno != ENOSYS)
+            {
+              utimensat_works_really = 1;
+              return result;
+            }
+        }
 # endif /* HAVE_FUTIMENS */
     }
   utimensat_works_really = -1;

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurel...@aurel32.net                 http://www.aurel32.net



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to