]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
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 8bbc93c6cbe538f030dc40937761178a9b37bff3..593de06d1ab047bc514f7068d75cc59c1b400e52 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 10b903d0762ba9a6c798fc6c8765dc7d9a3f9d00..c154deb40f215f6836f50e4eedc28e52d8c457d5 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 8b420153f16aa198cad9ec0dde5e903b33b16f75..051691230d797ceeff329121fd4c2e13a74846b9 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 0f731775b34d016a95ddfe7468c88d3c082d57ae..db43755694df6bb95a3aab4e35513f3bf531964a 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 7c96b780450435baadad8c4d17f80d16e37518c6..bb83e74faf2fc72f61df2df6b0d84b9b5c7724ba 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 1b9add40d7a72450c7edb51818b980c1394d9130..dd5c9bc684aea95947bc458bf4889e260c0bd29f 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 cb932b8e59d707b46689b457e31fa45ab56c5a42..442e4ca989361956392d2793d7294cd61abcc143 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 34acf10c2704d3b2c1a8e6361d48bfcd2fbb9793..1b02fde45947d1772b952b66679a37148e2dce9f 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 94f6e811863320d031e3a55bc9d70d2a8bdda9c5..37757937b35cca4995d77e96988f46698d63f5f5 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 cfd0e18223bdd35d9d5d05f0e6234de196147621..b2b7b0386b0c4f2d94e8dca22bccc6ead6a49212 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 3c190085cee8f15aab3e15eb24adf2182c729ea2..aa89d08730d3a8f2fb4d8e7f085f16a967a9fa4c 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 45b566f2d08df7e6a7de98c8d582719e2295af0d..7916c7110516fa41d991dfc9d0f4cd00739fb960 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 67c570648aedf4e0115982c1aaadee2f9745948e..46f6d97c6b0d53ac623a2a12e38b623a1438a715 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 1361596503727f8a7ba4bb2773ffe24bb14fd8ad..1e9a9b649f134fb971d8f9288af9feaf515750eb 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 86bb75a7b01549b2fa4e76966a89fcec67fe3d61..160bdc4903f710d761d087cac105058086a01b28 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 4cfc924bfcb447e5403841989292d4362e3809c8..d2704777bdec4585b7422a14c29b6ba4c58b2ebf 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 0a07a8a87534a7796eb136e614a7d21168f50d9e..bb5f89810bd40d1dbc6348e9efc4b1dd4a3ca9f0 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 8b1c932ba9afd9d173a93ff8655b6caa89c738da..cc41fdedc08ba96a5f38b8d3355d847dfd49e539 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 ef27b686cc29bc3b6ce6afc0f49ec186d7740235..177b3db9862e6e7fec568f8ca35f635bb63e4b2d 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/