Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: libiberty/make-relative-prefix.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libiberty/filename_cmp.c ('k') | libiberty/md5.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libiberty/make-relative-prefix.c
diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c
index 4553a7109d8244ec0ad572f6d5f415e7927824cf..fe639d18bd2815a5ec33aef28720386725ab1bd5 100644
--- a/libiberty/make-relative-prefix.c
+++ b/libiberty/make-relative-prefix.c
@@ -1,6 +1,6 @@
/* Relative (relocatable) prefix support.
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.
@@ -58,6 +58,9 @@ relative prefix can be found, return @code{NULL}.
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
#include <string.h>
@@ -245,10 +248,15 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
{
char *startp, *endp, *nstore;
size_t prefixlen = strlen (temp) + 1;
+ size_t len;
if (prefixlen < 2)
prefixlen = 2;
- nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
+ len = prefixlen + strlen (progname) + 1;
+#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
+ len += strlen (HOST_EXECUTABLE_SUFFIX);
+#endif
+ nstore = (char *) alloca (len);
startp = endp = temp;
while (1)
@@ -263,7 +271,7 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
}
else
{
- strncpy (nstore, startp, endp - startp);
+ memcpy (nstore, startp, endp - startp);
if (! IS_DIR_SEPARATOR (endp[-1]))
{
nstore[endp - startp] = DIR_SEPARATOR;
@@ -279,8 +287,14 @@ make_relative_prefix_1 (const char *progname, const char *bin_prefix,
#endif
)
{
- progname = nstore;
- break;
+#if defined (HAVE_SYS_STAT_H) && defined (S_ISREG)
+ struct stat st;
+ if (stat (nstore, &st) >= 0 && S_ISREG (st.st_mode))
+#endif
+ {
+ progname = nstore;
+ break;
+ }
}
if (*endp == 0)
« no previous file with comments | « libiberty/filename_cmp.c ('k') | libiberty/md5.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698