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.

--- tar-1.22.orig/lib/utimens.c
+++ tar-1.22/lib/utimens.c
@@ -120,16 +120,17 @@
     }
 #endif
 #if HAVE_FUTIMENS
-  {
-    int result = futimens (fd, timespec);
+  if (fd >= 0)
+    {
+      int result = futimens (fd, timespec);
 # 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
-    if (result == 0 || errno != ENOSYS)
-      return result;
-  }
+      if (result == 0 || errno != ENOSYS)
+        return result;
+    }
 #endif
 
   /* The platform lacks an interface to set file timestamps with

-- 
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