mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Consolidate definitions of _FORTIFY_SOURCE wrappers for open{,64}{,at}.
This commit is contained in:
19
ChangeLog
19
ChangeLog
@ -1,5 +1,24 @@
|
|||||||
2013-05-03 Roland McGrath <roland@hack.frob.com>
|
2013-05-03 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
|
* io/open.c (__open_2): Moved to ...
|
||||||
|
* io/open_2.c: ... this new file.
|
||||||
|
* io/open64.c (__open64_2): Moved to ...
|
||||||
|
* io/open64_2.c: ... this new file.
|
||||||
|
* io/openat.c (__openat_2): Moved to ...
|
||||||
|
* io/openat_2.c: ... this new file.
|
||||||
|
* io/openat64.c (__openat64_2): Moved to ...
|
||||||
|
* io/openat64_2.c: ... this new file.
|
||||||
|
* io/Makefile (routines): Add them.
|
||||||
|
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove them.
|
||||||
|
* sysdeps/unix/sysv/linux/open_2.c: File removed.
|
||||||
|
* sysdeps/unix/sysv/linux/open64_2.c: File removed.
|
||||||
|
* sysdeps/unix/sysv/linux/openat.c (__OPENAT_2): Removed.
|
||||||
|
* sysdeps/unix/sysv/linux/openat64.c (__OPENAT_2): Removed.
|
||||||
|
* sysdeps/unix/sysv/linux/wordsize-64/openat.c (__openat_2): Removed.
|
||||||
|
(__openat64): Add hidden_ver.
|
||||||
|
* sysdeps/mach/hurd/open.c (__open_2, __open64_2): Removed.
|
||||||
|
* sysdeps/mach/hurd/openat.c (__openat_2): Removed.
|
||||||
|
|
||||||
* elf/dl-sysdep.c (_dl_sysdep_start) [NEED_DL_SYSINFO]:
|
* elf/dl-sysdep.c (_dl_sysdep_start) [NEED_DL_SYSINFO]:
|
||||||
Separately conditionalize setting of GLRO(dl_sysinfo) so
|
Separately conditionalize setting of GLRO(dl_sysinfo) so
|
||||||
that the GLRO(dl_sysinfo_dso) test is under [NEED_DL_SYSINFO_DSO]
|
that the GLRO(dl_sysinfo_dso) test is under [NEED_DL_SYSINFO_DSO]
|
||||||
|
@ -36,10 +36,10 @@ routines := \
|
|||||||
statvfs fstatvfs statvfs64 fstatvfs64 \
|
statvfs fstatvfs statvfs64 fstatvfs64 \
|
||||||
umask chmod fchmod lchmod fchmodat \
|
umask chmod fchmod lchmod fchmodat \
|
||||||
mkdir mkdirat \
|
mkdir mkdirat \
|
||||||
open open64 openat openat64 close \
|
open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \
|
||||||
read write lseek lseek64 access euidaccess faccessat \
|
read write lseek lseek64 access euidaccess faccessat \
|
||||||
fcntl flock lockf lockf64 \
|
fcntl flock lockf lockf64 \
|
||||||
dup dup2 dup3 pipe pipe2 \
|
close dup dup2 dup3 pipe pipe2 \
|
||||||
creat creat64 \
|
creat creat64 \
|
||||||
chdir fchdir \
|
chdir fchdir \
|
||||||
getcwd getwd getdirname \
|
getcwd getwd getdirname \
|
||||||
|
14
io/open.c
14
io/open.c
@ -22,7 +22,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern char **__libc_argv attribute_hidden;
|
|
||||||
|
|
||||||
/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
|
/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
|
||||||
a third argument is the file protection. */
|
a third argument is the file protection. */
|
||||||
@ -57,15 +56,6 @@ weak_alias (__libc_open, open)
|
|||||||
|
|
||||||
stub_warning (open)
|
stub_warning (open)
|
||||||
|
|
||||||
|
/* __open_2 is a generic wrapper that calls __open.
|
||||||
int
|
So give a stub warning for that symbol too. */
|
||||||
__open_2 (file, oflag)
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid open call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __open (file, oflag);
|
|
||||||
}
|
|
||||||
stub_warning (__open_2)
|
stub_warning (__open_2)
|
||||||
|
13
io/open64.c
13
io/open64.c
@ -53,15 +53,6 @@ weak_alias (__libc_open64, open64)
|
|||||||
|
|
||||||
stub_warning (open64)
|
stub_warning (open64)
|
||||||
|
|
||||||
|
/* __open64_2 is a generic wrapper that calls __open64.
|
||||||
int
|
So give a stub warning for that symbol too. */
|
||||||
__open64_2 (file, oflag)
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid open64 call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __open64 (file, oflag);
|
|
||||||
}
|
|
||||||
stub_warning (__open64_2)
|
stub_warning (__open64_2)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
/* _FORTIFY_SOURCE wrapper for open64.
|
||||||
|
Copyright (C) 2013 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
|
||||||
@ -18,11 +19,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__open64_2 (file, oflag)
|
__open64_2 (const char *file, int oflag)
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
{
|
||||||
if (oflag & O_CREAT)
|
if (oflag & O_CREAT)
|
||||||
__fortify_fail ("invalid open64 call: O_CREAT without mode");
|
__fortify_fail ("invalid open64 call: O_CREAT without mode");
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
/* _FORTIFY_SOURCE wrapper for open.
|
||||||
|
Copyright (C) 2013 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
|
||||||
@ -18,11 +19,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__open_2 (file, oflag)
|
__open_2 (const char *file, int oflag)
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
{
|
||||||
if (oflag & O_CREAT)
|
if (oflag & O_CREAT)
|
||||||
__fortify_fail ("invalid open call: O_CREAT without mode");
|
__fortify_fail ("invalid open call: O_CREAT without mode");
|
14
io/openat.c
14
io/openat.c
@ -75,16 +75,6 @@ libc_hidden_def (__openat)
|
|||||||
weak_alias (__openat, openat)
|
weak_alias (__openat, openat)
|
||||||
stub_warning (openat)
|
stub_warning (openat)
|
||||||
|
|
||||||
|
/* __openat_2 is a generic wrapper that calls __openat.
|
||||||
int
|
So give a stub warning for that symbol too. */
|
||||||
__openat_2 (fd, file, oflag)
|
|
||||||
int fd;
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid openat call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __openat (fd, file, oflag);
|
|
||||||
}
|
|
||||||
stub_warning (__openat_2)
|
stub_warning (__openat_2)
|
||||||
|
@ -68,16 +68,6 @@ libc_hidden_def (__openat64)
|
|||||||
weak_alias (__openat64, openat64)
|
weak_alias (__openat64, openat64)
|
||||||
stub_warning (openat64)
|
stub_warning (openat64)
|
||||||
|
|
||||||
|
/* __openat64_2 is a generic wrapper that calls __openat64.
|
||||||
int
|
So give a stub warning for that symbol too. */
|
||||||
__openat64_2 (fd, file, oflag)
|
|
||||||
int fd;
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid openat64 call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __openat64 (fd, file, oflag);
|
|
||||||
}
|
|
||||||
stub_warning (__openat_2)
|
stub_warning (__openat_2)
|
||||||
|
29
io/openat64_2.c
Normal file
29
io/openat64_2.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* _FORTIFY_SOURCE wrapper for openat64.
|
||||||
|
Copyright (C) 2013 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
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
__openat64_2 (int fd, const char *file, int oflag)
|
||||||
|
{
|
||||||
|
if (oflag & O_CREAT)
|
||||||
|
__fortify_fail ("invalid openat64 call: O_CREAT without mode");
|
||||||
|
|
||||||
|
return __openat64 (fd, file, oflag);
|
||||||
|
}
|
29
io/openat_2.c
Normal file
29
io/openat_2.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* _FORTIFY_SOURCE wrapper for openat.
|
||||||
|
Copyright (C) 2013 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
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
__openat_2 (int fd, const char *file, int oflag)
|
||||||
|
{
|
||||||
|
if (oflag & O_CREAT)
|
||||||
|
__fortify_fail ("invalid openat call: O_CREAT without mode");
|
||||||
|
|
||||||
|
return __openat (fd, file, oflag);
|
||||||
|
}
|
@ -52,20 +52,9 @@ weak_alias (__libc_open, __open)
|
|||||||
libc_hidden_weak (__open)
|
libc_hidden_weak (__open)
|
||||||
weak_alias (__libc_open, open)
|
weak_alias (__libc_open, open)
|
||||||
|
|
||||||
int
|
|
||||||
__open_2 (file, oflag)
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid open call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __open (file, oflag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open64 is just the same as open for us. */
|
/* open64 is just the same as open for us. */
|
||||||
weak_alias (__libc_open, __libc_open64)
|
weak_alias (__libc_open, __libc_open64)
|
||||||
weak_alias (__libc_open, __open64)
|
weak_alias (__libc_open, __open64)
|
||||||
libc_hidden_weak (_open64)
|
libc_hidden_weak (_open64)
|
||||||
weak_alias (__libc_open, open64)
|
weak_alias (__libc_open, open64)
|
||||||
strong_alias (__open_2, __open64_2)
|
|
||||||
|
@ -56,20 +56,7 @@ __openat (fd, file, oflag)
|
|||||||
libc_hidden_def (__openat)
|
libc_hidden_def (__openat)
|
||||||
weak_alias (__openat, openat)
|
weak_alias (__openat, openat)
|
||||||
|
|
||||||
int
|
|
||||||
__openat_2 (fd, file, oflag)
|
|
||||||
int fd;
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
__fortify_fail ("invalid openat call: O_CREAT without mode");
|
|
||||||
|
|
||||||
return __openat (fd, file, oflag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* openat64 is just the same as openat for us. */
|
/* openat64 is just the same as openat for us. */
|
||||||
weak_alias (__openat, __openat64)
|
weak_alias (__openat, __openat64)
|
||||||
libc_hidden_weak (__openat64)
|
libc_hidden_weak (__openat64)
|
||||||
weak_alias (__openat, openat64)
|
weak_alias (__openat, openat64)
|
||||||
strong_alias (__openat_2, __openat64_2)
|
|
||||||
|
@ -152,7 +152,7 @@ endif
|
|||||||
|
|
||||||
ifeq ($(subdir),io)
|
ifeq ($(subdir),io)
|
||||||
sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
|
sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
|
||||||
sync_file_range open_2 open64_2 fallocate fallocate64
|
sync_file_range fallocate fallocate64
|
||||||
sysdep_headers += bits/fcntl-linux.h
|
sysdep_headers += bits/fcntl-linux.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#ifndef OPENAT
|
#ifndef OPENAT
|
||||||
# define OPENAT openat
|
# define OPENAT openat
|
||||||
# define __OPENAT_2 __openat_2
|
|
||||||
|
|
||||||
# ifndef __ASSUME_ATFCTS
|
# ifndef __ASSUME_ATFCTS
|
||||||
/* Set errno after a failed call. If BUF is not null,
|
/* Set errno after a failed call. If BUF is not null,
|
||||||
@ -179,18 +178,3 @@ __OPENAT (fd, file, oflag)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (__OPENAT)
|
libc_hidden_def (__OPENAT)
|
||||||
weak_alias (__OPENAT, OPENAT)
|
weak_alias (__OPENAT, OPENAT)
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
__OPENAT_2 (fd, file, oflag)
|
|
||||||
int fd;
|
|
||||||
const char *file;
|
|
||||||
int oflag;
|
|
||||||
{
|
|
||||||
if (oflag & O_CREAT)
|
|
||||||
#define MSG(s) MSG2 (s)
|
|
||||||
#define MSG2(s) "invalid " #s " call: O_CREAT without mode"
|
|
||||||
__fortify_fail (MSG (OPENAT));
|
|
||||||
|
|
||||||
return __OPENAT (fd, file, oflag);
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#define OPENAT openat64
|
#define OPENAT openat64
|
||||||
#define __OPENAT_2 __openat64_2
|
|
||||||
#define MORE_OFLAGS O_LARGEFILE
|
#define MORE_OFLAGS O_LARGEFILE
|
||||||
|
|
||||||
#include "openat.c"
|
#include "openat.c"
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#define __openat64 __rename___openat64
|
#define __openat64 __rename___openat64
|
||||||
#define __openat64_2 __rename___openat64_2
|
|
||||||
#define __openat64_nocancel __rename___openat64_nocancel
|
#define __openat64_nocancel __rename___openat64_nocancel
|
||||||
#define openat64 __rename_openat64
|
#define openat64 __rename_openat64
|
||||||
|
|
||||||
#include "../openat.c"
|
#include "../openat.c"
|
||||||
|
|
||||||
#undef __openat64
|
#undef __openat64
|
||||||
#undef __openat64_2
|
|
||||||
#undef __openat64_nocancel
|
#undef __openat64_nocancel
|
||||||
#undef openat64
|
#undef openat64
|
||||||
|
|
||||||
weak_alias (__openat, __openat64)
|
strong_alias (__openat, __openat64)
|
||||||
weak_alias (__openat_2, __openat64_2)
|
hidden_ver (__openat, __openat64)
|
||||||
weak_alias (__openat_nocancel, __openat64_nocancel)
|
strong_alias (__openat_nocancel, __openat64_nocancel)
|
||||||
weak_alias (openat, openat64)
|
weak_alias (openat, openat64)
|
||||||
|
Reference in New Issue
Block a user