mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-08 15:56:07 +08:00
merge from gcc
This commit is contained in:
libiberty
@ -1,3 +1,14 @@
|
|||||||
|
2012-01-02 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* make-relative-prefix.c (make_relative_prefix_1): Avoid
|
||||||
|
stack overflow if PATH contains just a single entry and
|
||||||
|
HOST_EXECUTABLE_SUFFIX needs to be used.
|
||||||
|
|
||||||
|
PR driver/48306
|
||||||
|
* make-relative-prefix.c: Include sys/stat.h.
|
||||||
|
(make_relative_prefix_1): If access succeeds, check also stat
|
||||||
|
if nstore is a regular file.
|
||||||
|
|
||||||
2011-12-20 Andreas Schwab <schwab@linux-m68k.org>
|
2011-12-20 Andreas Schwab <schwab@linux-m68k.org>
|
||||||
|
|
||||||
* configure: Regenerate.
|
* configure: Regenerate.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Relative (relocatable) prefix support.
|
/* Relative (relocatable) prefix support.
|
||||||
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2006, 2012 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of libiberty.
|
This file is part of libiberty.
|
||||||
|
|
||||||
@ -58,6 +58,9 @@ relative prefix can be found, return @code{NULL}.
|
|||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SYS_STAT_H
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -248,7 +251,11 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
|
|||||||
if (prefixlen < 2)
|
if (prefixlen < 2)
|
||||||
prefixlen = 2;
|
prefixlen = 2;
|
||||||
|
|
||||||
nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
|
nstore = (char *) alloca (prefixlen + strlen (progname) + 1
|
||||||
|
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
|
||||||
|
+ strlen (HOST_EXECUTABLE_SUFFIX)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
startp = endp = temp;
|
startp = endp = temp;
|
||||||
while (1)
|
while (1)
|
||||||
@ -263,7 +270,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy (nstore, startp, endp - startp);
|
memcpy (nstore, startp, endp - startp);
|
||||||
if (! IS_DIR_SEPARATOR (endp[-1]))
|
if (! IS_DIR_SEPARATOR (endp[-1]))
|
||||||
{
|
{
|
||||||
nstore[endp - startp] = DIR_SEPARATOR;
|
nstore[endp - startp] = DIR_SEPARATOR;
|
||||||
@ -279,8 +286,14 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
progname = nstore;
|
#if defined (HAVE_SYS_STAT_H) && defined (S_ISREG)
|
||||||
break;
|
struct stat st;
|
||||||
|
if (stat (nstore, &st) >= 0 && S_ISREG (st.st_mode))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
progname = nstore;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*endp == 0)
|
if (*endp == 0)
|
||||||
|
Reference in New Issue
Block a user