From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.4 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id D41A91F619 for ; Sat, 7 Mar 2020 03:49:02 +0000 (UTC) Received: from localhost ([::1]:44784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAQST-0005JA-BY for normalperson@yhbt.net; Fri, 06 Mar 2020 22:49:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41982) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAQSP-0005J3-E1 for bug-gnulib@gnu.org; Fri, 06 Mar 2020 22:48:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAQSN-00047B-1L for bug-gnulib@gnu.org; Fri, 06 Mar 2020 22:48:57 -0500 Received: from mail-qv1-f48.google.com ([209.85.219.48]:42370) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jAQSM-00045o-U2 for bug-gnulib@gnu.org; Fri, 06 Mar 2020 22:48:54 -0500 Received: by mail-qv1-f48.google.com with SMTP id e7so1951355qvy.9 for ; Fri, 06 Mar 2020 19:48:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=d+gxWXXudIFm8r80rp8lrKOz15dSTNfyGhwpBCfByl0=; b=TIxOXHdIQVlQYEx0DoNs6Rcc2hlxz5/WxRtDh472LFkzxV9kA8j8bplfqv6fTP+rjN UqQ85ub8RvpxMeOkZZQNSbZH/4Pds/Vkf3grUf3VqiDkFF+beEgRtw1XdRUbRN45Urj7 N7bpZrrXYY5sGMT3Z+hvU2VT38VtLaLRMkMSnWoKgm1dHlwgUrf5V9CGM7ENRZkJJwWa wt9pNJpQX+zTabbXxB0fRfPJk2GQWFF6ZJL2ZR+zQkZc2WTk1x6Imw7jECPRJkX7wszx qDtS9Lqt2SWw1wP+VBl8WIVaQN+clKdkCQp0+gtIMGTwxXboHXTiyrlEbl59yNNQxuZN +I+A== X-Gm-Message-State: ANhLgQ01eWTfhrikSDdYUtxydipobXg3q+FnC6/qKUR3pUIr/BLiUVLG lv1R3TQut12pfkh780VeMYnfd31CJtn80MDTZeJBDxFnZbI= X-Google-Smtp-Source: ADFU+vsWtKM+2iaRZcWOusmlYCFK7iAThobJyC7oFxEsKiAadKsIWOZgRqN/g8g9EJu1wAFgiVOGm5cuMyO7F3/rc1c= X-Received: by 2002:a05:6214:287:: with SMTP id l7mr6024177qvv.142.1583552933995; Fri, 06 Mar 2020 19:48:53 -0800 (PST) MIME-Version: 1.0 Date: Fri, 6 Mar 2020 22:48:43 -0500 Message-ID: Subject: patch, have find_in_given_path return file only To: bug-gnulib@gnu.org Content-Type: text/plain; charset="UTF-8" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.219.48 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Reply-to: Dmitry Goncharov From: Dmitry Goncharov via Gnulib discussion list 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 #include #include +#include #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)