mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 16:21:06 +00:00
(dl_main): First check existence of ld.so.preload with access.
This commit is contained in:
parent
6698501fda
commit
761490a1d7
21
elf/rtld.c
21
elf/rtld.c
@ -1138,8 +1138,16 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
HP_TIMING_ACCUM_NT (load_time, diff);
|
||||
}
|
||||
|
||||
/* There usually is no ld.so.preload file, it should only be used
|
||||
for emergencies and testing. So the open call etc should usually
|
||||
fail. Using access() on a non-existing file is faster than using
|
||||
open(). So we do this first. If it succeeds we do almost twice
|
||||
the work but this does not matter, since it is not for production
|
||||
use. */
|
||||
static const char preload_file[] = "/etc/ld.so.preload";
|
||||
if (__builtin_expect (__access (preload_file, R_OK) == 0, 0))
|
||||
{
|
||||
/* Read the contents of the file. */
|
||||
const char preload_file[] = "/etc/ld.so.preload";
|
||||
file = _dl_sysdep_read_whole_file (preload_file, &file_size,
|
||||
PROT_READ | PROT_WRITE);
|
||||
if (__builtin_expect (file != MAP_FAILED, 0))
|
||||
@ -1173,7 +1181,8 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
&& file[file_size - 1] != '\n' && file[file_size - 1] != ':')
|
||||
{
|
||||
problem = &file[file_size];
|
||||
while (problem > file && problem[-1] != ' ' && problem[-1] != '\t'
|
||||
while (problem > file && problem[-1] != ' '
|
||||
&& problem[-1] != '\t'
|
||||
&& problem[-1] != '\n' && problem[-1] != ':')
|
||||
--problem;
|
||||
|
||||
@ -1204,14 +1213,15 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
args.is_preloaded = 1;
|
||||
args.mode = 0;
|
||||
|
||||
(void) _dl_catch_error (&objname, &err_str, map_doit, &args);
|
||||
(void) _dl_catch_error (&objname, &err_str, map_doit,
|
||||
&args);
|
||||
if (__builtin_expect (err_str != NULL, 0))
|
||||
{
|
||||
_dl_error_printf ("\
|
||||
ERROR: ld.so: object '%s' from %s cannot be preloaded: ignored.\n",
|
||||
p, preload_file);
|
||||
/* No need to call free, this is still before the libc's
|
||||
malloc is used. */
|
||||
/* No need to call free, this is still before
|
||||
the libc's malloc is used. */
|
||||
}
|
||||
else if (++args.map->l_opencount == 1)
|
||||
/* It is no duplicate. */
|
||||
@ -1236,6 +1246,7 @@ ERROR: ld.so: object '%s' from %s cannot be preloaded: ignored.\n",
|
||||
/* We don't need the file anymore. */
|
||||
__munmap (file, file_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (__builtin_expect (npreloads, 0) != 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user