Fix compat handling in *at functions.
authorUlrich Drepper <drepper@redhat.com>
Fri, 30 Oct 2009 04:33:26 +0000 (21:33 -0700)
committerUlrich Drepper <drepper@redhat.com>
Fri, 30 Oct 2009 04:33:26 +0000 (21:33 -0700)
When passed an empty string for the filename, the compat code
using /proc in all *at functions did the wrong thing.

19 files changed:
ChangeLog
sysdeps/unix/sysv/linux/faccessat.c
sysdeps/unix/sysv/linux/fchmodat.c
sysdeps/unix/sysv/linux/fchownat.c
sysdeps/unix/sysv/linux/futimesat.c
sysdeps/unix/sysv/linux/fxstatat.c
sysdeps/unix/sysv/linux/fxstatat64.c
sysdeps/unix/sysv/linux/i386/fchownat.c
sysdeps/unix/sysv/linux/i386/fxstatat.c
sysdeps/unix/sysv/linux/linkat.c
sysdeps/unix/sysv/linux/mkdirat.c
sysdeps/unix/sysv/linux/openat.c
sysdeps/unix/sysv/linux/powerpc/fchownat.c
sysdeps/unix/sysv/linux/readlinkat.c
sysdeps/unix/sysv/linux/renameat.c
sysdeps/unix/sysv/linux/symlinkat.c
sysdeps/unix/sysv/linux/unlinkat.c
sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
sysdeps/unix/sysv/linux/xmknodat.c

index 8bbc93c..593de06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2009-10-29  Ulrich Drepper  <drepper@redhat.com>
 
+       [BZ #10609]
+       * sysdeps/unix/sysv/linux/faccessat.c: Fix handling of empty parameters
+       for file names in case the syscall is not available.
+       * sysdeps/unix/sysv/linux/fchmodat.c: Likewise.
+       * sysdeps/unix/sysv/linux/fchownat.c: Likewise.
+       * sysdeps/unix/sysv/linux/futimesat.c: Likewise.
+       * sysdeps/unix/sysv/linux/fxstatat.c: Likewise.
+       * sysdeps/unix/sysv/linux/fxstatat64.c: Likewise.
+       * sysdeps/unix/sysv/linux/i386/fchownat.c: Likewise.
+       * sysdeps/unix/sysv/linux/i386/fxstatat.c: Likewise.
+       * sysdeps/unix/sysv/linux/linkat.c: Likewise.
+       * sysdeps/unix/sysv/linux/mkdirat.c: Likewise.
+       * sysdeps/unix/sysv/linux/openat.c: Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/fchownat.c: Likewise.
+       * sysdeps/unix/sysv/linux/readlinkat.c: Likewise.
+       * sysdeps/unix/sysv/linux/renameat.c: Likewise.
+       * sysdeps/unix/sysv/linux/symlinkat.c: Likewise.
+       * sysdeps/unix/sysv/linux/unlinkat.c: Likewise.
+       * sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c: Likewise.
+       * sysdeps/unix/sysv/linux/xmknodat.c: Likewise.
+
        [BZ #10643]
        * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): If thread
        creation filed, remove the request from the 'requests' list and signal
index 10b903d..c154deb 100644 (file)
@@ -1,5 +1,5 @@
 /* Test for access to file, relative to open directory.  Linux version.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -72,6 +72,12 @@ faccessat (fd, file, mode, flag)
       if (fd != AT_FDCWD && file[0] != '/')
        {
          size_t filelen = strlen (file);
+         if (__builtin_expect (filelen == 0, 0))
+           {
+             __set_errno (ENOENT);
+             return -1;
+           }
+
          static const char procfd[] = "/proc/self/fd/%d/%s";
          /* Buffer for the path name we are going to use.  It consists of
             - the string /proc/self/fd/
index 8b42015..0516912 100644 (file)
@@ -1,5 +1,5 @@
 /* Change the protections of file relative to open directory.  Linux version.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -71,6 +71,12 @@ fchmodat (fd, file, mode, flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 0f73177..db43755 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -66,6 +66,12 @@ fchownat (fd, file, owner, group, flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 7c96b78..bb83e74 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -76,6 +76,12 @@ futimesat (fd, file, tvp)
   else if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 1b9add4..dd5c9bc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -85,6 +85,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index cb932b8..442e4ca 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -90,6 +90,12 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 34acf10..1b02fde 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -63,6 +63,12 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 94f6e81..3775793 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -86,6 +86,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index cfd0e18..b2b7b03 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -66,6 +66,12 @@ linkat (fromfd, from, tofd, to, flags)
   if (fromfd != AT_FDCWD && from[0] != '/')
     {
       size_t filelen = strlen (from);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
         - the file descriptor number
index 3c19008..aa89d08 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -57,6 +57,12 @@ mkdirat (fd, file, mode)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 45b566f..7916c71 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -110,6 +110,12 @@ OPENAT_NOT_CANCEL (fd, file, oflag, mode)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 67c5706..46f6d97 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -66,6 +66,12 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 1361596..1e9a9b6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -59,6 +59,12 @@ readlinkat (fd, path, buf, len)
   if (fd != AT_FDCWD && path[0] != '/')
     {
       size_t pathlen = strlen (path);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 86bb75a..160bdc4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -135,6 +135,12 @@ renameat (oldfd, old, newfd, new)
   if (oldfd != AT_FDCWD && old[0] != '/')
     {
       size_t filelen = strlen (old);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
         - the file descriptor number
@@ -154,6 +160,12 @@ renameat (oldfd, old, newfd, new)
   if (newfd != AT_FDCWD && new[0] != '/')
     {
       size_t filelen = strlen (new);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
         - the file descriptor number
index 4cfc924..d270477 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -57,6 +57,12 @@ symlinkat (from, tofd, to)
   if (tofd != AT_FDCWD && to[0] != '/')
     {
       size_t tolen = strlen (to);
+      if (__builtin_expect (tolen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 0a07a8a..bb5f898 100644 (file)
@@ -1,5 +1,5 @@
 /* unlinkat -- Remove a link by relative name.
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -64,6 +64,12 @@ unlinkat (fd, file, flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index 8b1c932..cc41fde 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -72,6 +72,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/
index ef27b68..177b3db 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -72,6 +72,12 @@ __xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev)
   if (fd != AT_FDCWD && file[0] != '/')
     {
       size_t filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+       {
+         __set_errno (ENOENT);
+         return -1;
+       }
+
       static const char procfd[] = "/proc/self/fd/%d/%s";
       /* Buffer for the path name we are going to use.  It consists of
         - the string /proc/self/fd/