From 8c121ccb537f02ade6f9fdb67f13f24b3c94c48d Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 14 Nov 2011 21:44:01 +0000 Subject: [PATCH] * gcov.c (canonicalize_name): Protect use of S_ISLNK. From-SVN: r181367 --- gcc/ChangeLog | 4 ++++ gcc/gcov.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7c6952e517..94661b5d61d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2011-11-14 Nathan Sidwell + + * gcov.c (canonicalize_name): Protect use of S_ISLNK. + 2011-11-14 Jan Hubicka * config/i386/i386.c (core cost model): Correct pasto. diff --git a/gcc/gcov.c b/gcc/gcov.c index dffb827bdf7..c5cc0efdf1a 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -1688,10 +1688,15 @@ canonicalize_name (const char *name) { /* '..', we can only elide it and the previous directory, if we're not a symlink. */ - struct stat buf; - + struct stat ATTRIBUTE_UNUSED buf; + *ptr = 0; - if (dd_base == ptr || stat (result, &buf) || S_ISLNK (buf.st_mode)) + if (dd_base == ptr +#if defined (S_ISLNK) + /* S_ISLNK is not POSIX.1-1996. */ + || stat (result, &buf) || S_ISLNK (buf.st_mode) +#endif + ) { /* Cannot elide, or unreadable or a symlink. */ dd_base = ptr + 2 + slash; -- 2.30.2