Fix compat handling in *at functions.

When passed an empty string for the filename, the compat code
using /proc in all *at functions did the wrong thing.
This commit is contained in:
Ulrich Drepper 2009-10-29 21:33:26 -07:00
parent 584715c3a9
commit 801720e63b
19 changed files with 153 additions and 18 deletions

View File

@ -1,5 +1,26 @@
2009-10-29 Ulrich Drepper <drepper@redhat.com> 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] [BZ #10643]
* sysdeps/pthread/aio_misc.c (__aio_enqueue_request): If thread * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): If thread
creation filed, remove the request from the 'requests' list and signal creation filed, remove the request from the 'requests' list and signal

View File

@ -1,5 +1,5 @@
/* Test for access to file, relative to open directory. Linux version. /* 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View File

@ -1,5 +1,5 @@
/* Change the protections of file relative to open directory. Linux version. /* 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') else if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fromfd != AT_FDCWD && from[0] != '/')
{ {
size_t filelen = strlen (from); 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 /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/
- the file descriptor number - the file descriptor number

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && path[0] != '/')
{ {
size_t pathlen = strlen (path); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (oldfd != AT_FDCWD && old[0] != '/')
{ {
size_t filelen = strlen (old); 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 /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/
- the file descriptor number - the file descriptor number
@ -154,6 +160,12 @@ renameat (oldfd, old, newfd, new)
if (newfd != AT_FDCWD && new[0] != '/') if (newfd != AT_FDCWD && new[0] != '/')
{ {
size_t filelen = strlen (new); 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 /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/
- the file descriptor number - the file descriptor number

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (tofd != AT_FDCWD && to[0] != '/')
{ {
size_t tolen = strlen (to); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View File

@ -1,5 +1,5 @@
/* unlinkat -- Remove a link by relative name. /* 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/

View 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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] != '/') if (fd != AT_FDCWD && file[0] != '/')
{ {
size_t filelen = strlen (file); 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"; static const char procfd[] = "/proc/self/fd/%d/%s";
/* Buffer for the path name we are going to use. It consists of /* Buffer for the path name we are going to use. It consists of
- the string /proc/self/fd/ - the string /proc/self/fd/