From: Dmitry Goncharov via Gnulib discussion list <bug-gnulib@gnu.org>
To: bug-gnulib@gnu.org
Subject: patch, have find_in_given_path return file only
Date: Fri, 6 Mar 2020 22:48:43 -0500 [thread overview]
Message-ID: <CAG+Z0CsFjS2-5xvkPZqmx_JWoqt3Lwv+bsEQomZWR=Akzi82qQ@mail.gmail.com> (raw)
Good morning.
A user reporter an issue in gnu make.
https://savannah.gnu.org/bugs/index.php?57962.
The issue is that find_in_given_path returns a directory which matches
the desired name.
The fix is likely needed for the windows specific piece of code in
find_in_given_path as well.
regards, Dmitry
diff --git a/lib/findprog-in.c b/lib/findprog-in.c
index c254f2f..d89ec00 100644
--- a/lib/findprog-in.c
+++ b/lib/findprog-in.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "filename.h"
#include "concat-filename.h"
@@ -190,6 +191,7 @@ find_in_given_path (const char *progname, const char *path,
dir = ".";
/* Try all platform-dependent suffixes. */
+ struct stat st;
for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
{
const char *suffix = suffixes[i];
@@ -208,7 +210,8 @@ find_in_given_path (const char *progname, const char *path,
use it. On other systems, let's hope that this program
is not installed setuid or setgid, so that it is ok to
call access() despite its design flaw. */
- if (eaccess (progpathname, X_OK) == 0)
+ if (eaccess (progpathname, X_OK) == 0 &&
+ stat(progpathname, &st) == 0 && S_ISREG(st.st_mode))
{
/* Found! */
if (strcmp (progpathname, progname) == 0)
next reply other threads:[~2020-03-07 3:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-07 3:48 Dmitry Goncharov via Gnulib discussion list [this message]
2020-03-07 18:57 ` patch, have find_in_given_path return file only Bruno Haible
2020-04-10 14:00 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAG+Z0CsFjS2-5xvkPZqmx_JWoqt3Lwv+bsEQomZWR=Akzi82qQ@mail.gmail.com' \
--to=bug-gnulib@gnu.org \
--cc=dgoncharov@users.sf.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).