Update.
2001-11-09 Ulrich Drepper <drepper@redhat.com> * elf/dl-minimal.c (realloc): Handle NULL for first parameter correctly. * elf/dl-load.c (is_dst): New function. (_dl_dst_count): Use is_dst to check for DST variable. (_dl_dst_substitute): Likewise.
This commit is contained in:
parent
d252c4796b
commit
6d5d3ae3d6
|
@ -1,3 +1,11 @@
|
||||||
|
2001-11-09 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-minimal.c (realloc): Handle NULL for first parameter
|
||||||
|
correctly.
|
||||||
|
* elf/dl-load.c (is_dst): New function.
|
||||||
|
(_dl_dst_count): Use is_dst to check for DST variable.
|
||||||
|
(_dl_dst_substitute): Likewise.
|
||||||
|
|
||||||
2001-11-09 Roland McGrath <roland@frob.com>
|
2001-11-09 Roland McGrath <roland@frob.com>
|
||||||
|
|
||||||
Hurd/PowerPC port contributed by Peter Bruin <pjbruin@dds.nl>.
|
Hurd/PowerPC port contributed by Peter Bruin <pjbruin@dds.nl>.
|
||||||
|
|
|
@ -170,6 +170,30 @@ local_strdup (const char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
is_dst (const char *start, const char *name, const char *str, size_t cmplen, int is_path,
|
||||||
|
int secure)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (strncmp (name, str, cmplen) == 0)
|
||||||
|
len = cmplen + 1;
|
||||||
|
else if (strncmp (name, str + 1, cmplen - 2) == 0
|
||||||
|
&& (name[cmplen - 2] == '\0' || name[cmplen - 2] == '/'
|
||||||
|
|| (is_path && name[cmplen - 2] == ':')))
|
||||||
|
len = cmplen - 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (__builtin_expect (secure, 0)
|
||||||
|
&& ((name[len - 1] != '\0' && (!is_path || name[len - 1] != ':'))
|
||||||
|
|| (name != start + 1 && (!is_path || name[-2] != ':'))))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
_dl_dst_count (const char *name, int is_path)
|
_dl_dst_count (const char *name, int is_path)
|
||||||
{
|
{
|
||||||
|
@ -186,23 +210,10 @@ _dl_dst_count (const char *name, int is_path)
|
||||||
Note that it is no bug that the string in the second and
|
Note that it is no bug that the string in the second and
|
||||||
fourth `strncmp' call is longer than the sequence which is
|
fourth `strncmp' call is longer than the sequence which is
|
||||||
actually tested. */
|
actually tested. */
|
||||||
if (((strncmp (&name[1], "{ORIGIN}", 8) == 0 && (len = 9) != 0)
|
if ((len = is_dst (start, name + 1, "{ORIGIN}", 8, is_path,
|
||||||
|| (strncmp (&name[1], "{ORIGIN}" + 1, 6) == 0
|
__libc_enable_secure)) != 0
|
||||||
&& (name[7] == '\0' || name[7] == '/'
|
|| ((len = is_dst (start, name + 1, "{PLATFORM}", 10, is_path, 0))
|
||||||
|| (is_path && name[7] == ':'))
|
!= 0))
|
||||||
&& (len = 7) != 0)))
|
|
||||||
{
|
|
||||||
if ((__builtin_expect (!__libc_enable_secure, 1)
|
|
||||||
|| name[len] == '\0' || (is_path && name[len] == ':'))
|
|
||||||
&& (name == start || (is_path && name[-1] == ':')))
|
|
||||||
++cnt;
|
|
||||||
}
|
|
||||||
else if ((strncmp (&name[1], "{PLATFORM}", 10) == 0
|
|
||||||
&& (len = 11) != 0)
|
|
||||||
|| (strncmp (&name[1], "{PLATFORM}" + 1, 8) == 0
|
|
||||||
&& (name[9] == '\0' || name[9] == '/'
|
|
||||||
|| (is_path && name[9] == ':'))
|
|
||||||
&& (len = 9) != 0))
|
|
||||||
++cnt;
|
++cnt;
|
||||||
|
|
||||||
name = strchr (name + len, '$');
|
name = strchr (name + len, '$');
|
||||||
|
@ -236,25 +247,13 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
|
||||||
/* Note that it is no bug that the string in the second and
|
/* Note that it is no bug that the string in the second and
|
||||||
fourth `strncmp' call is longer than the sequence which
|
fourth `strncmp' call is longer than the sequence which
|
||||||
is actually tested. */
|
is actually tested. */
|
||||||
if (((strncmp (&name[1], "{ORIGIN}", 8) == 0 && (len = 9) != 0)
|
if ((len = is_dst (start, name + 1, "{ORIGIN}", 8, is_path,
|
||||||
|| (strncmp (&name[1], "{ORIGIN}" + 1, 6) == 0
|
__libc_enable_secure)) != 0)
|
||||||
&& (name[7] == '\0' || name[7] == '/'
|
repl = l->l_origin;
|
||||||
|| (is_path && name[7] == ':'))
|
else if ((len = is_dst (start, name + 1, "{PLATFORM}", 10, is_path,
|
||||||
&& (len = 7) != 0)))
|
0)) != 0)
|
||||||
{
|
|
||||||
if ((__builtin_expect (!__libc_enable_secure, 1)
|
|
||||||
|| name[len] == '\0' || (is_path && name[len] == ':'))
|
|
||||||
&& (name == start || (is_path && name[-1] == ':')))
|
|
||||||
repl = l->l_origin;
|
|
||||||
}
|
|
||||||
else if ((strncmp (&name[1], "{PLATFORM}", 10) == 0
|
|
||||||
&& (len = 11) != 0)
|
|
||||||
|| (strncmp (&name[1], "{PLATFORM}" + 1, 8) == 0
|
|
||||||
&& (name[9] == '\0' || name[9] == '/' || name[9] == ':')
|
|
||||||
&& (len = 9) != 0))
|
|
||||||
repl = _dl_platform;
|
repl = _dl_platform;
|
||||||
|
|
||||||
|
|
||||||
if (repl != NULL && repl != (const char *) -1)
|
if (repl != NULL && repl != (const char *) -1)
|
||||||
{
|
{
|
||||||
wp = __stpcpy (wp, repl);
|
wp = __stpcpy (wp, repl);
|
||||||
|
@ -747,7 +746,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
|
||||||
is to avoid the function from being inlined. There is no official
|
is to avoid the function from being inlined. There is no official
|
||||||
way to do this so we use this trick. gcc never inlines functions
|
way to do this so we use this trick. gcc never inlines functions
|
||||||
which use `alloca'. */
|
which use `alloca'. */
|
||||||
int *a = alloca (sizeof (int));
|
int *a = (int *) alloca (sizeof (int));
|
||||||
a[0] = fd;
|
a[0] = fd;
|
||||||
/* The file might already be closed. */
|
/* The file might already be closed. */
|
||||||
if (a[0] != -1)
|
if (a[0] != -1)
|
||||||
|
|
Loading…
Reference in New Issue