From 1124b8285f983fe1384734e8429c43a1ac49c4c5 Mon Sep 17 00:00:00 2001 From: fandeyuan Date: Tue, 30 Apr 2024 14:25:06 +0800 Subject: [PATCH] which fails for long path --- 0001-which-fails-for-long-path.patch | 59 ++++++++++++++++++++++++++++ which.spec | 10 ++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 0001-which-fails-for-long-path.patch diff --git a/0001-which-fails-for-long-path.patch b/0001-which-fails-for-long-path.patch new file mode 100644 index 0000000..c2177d6 --- /dev/null +++ b/0001-which-fails-for-long-path.patch @@ -0,0 +1,59 @@ +From 77420bf2e35444f348b19e0acaf1f77bb4ed3f76 Mon Sep 17 00:00:00 2001 +From: fandeyuan +Date: Tue, 30 Apr 2024 14:18:20 +0800 +Subject: [PATCH] which fails for long path + +--- + which.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/which.c b/which.c +index 1606052..525c0d0 100644 +--- a/which.c ++++ b/which.c +@@ -19,10 +19,15 @@ + #include "sys.h" + #include + #include ++#include + #include "getopt.h" + #include "tilde/tilde.h" + #include "bash.h" + ++#ifndef PATH_MAX ++#define PATH_MAX 4096 ++#endif ++ + static const char *progname; + + static void print_usage(FILE *out) +@@ -63,7 +68,7 @@ static void print_fail(const char *name, const char *path_list) + fprintf(stderr, "%s: no %s in (%s)\n", progname, name, path_list); + } + +-static char home[256]; ++static char home[PATH_MAX]; + static size_t homelen = 0; + + static int absolute_path_given; +@@ -162,7 +167,7 @@ static char *find_command_in_path(const char *name, const char *path_list, int * + return (found); + } + +-static char cwd[256]; ++static char cwd[PATH_MAX]; + static size_t cwdlen; + + static void get_current_working_directory(void) +@@ -194,7 +199,7 @@ static void get_current_working_directory(void) + + static char *path_clean_up(const char *path) + { +- static char result[256]; ++ static char result[PATH_MAX]; + + const char *p1 = path; + char *p2 = result; +-- +2.33.0 + diff --git a/which.spec b/which.spec index 7c3f4d6..f465913 100644 --- a/which.spec +++ b/which.spec @@ -1,11 +1,13 @@ Name: which Version: 2.21 -Release: 15 +Release: 16 Summary: Show the full path of commands License: GPLv3 URL: https://savannah.gnu.org/projects/which/ Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz +Patch1: 0001-which-fails-for-long-path.patch + BuildRequires: gcc %description @@ -40,6 +42,12 @@ rm -f %{buildroot}/%{_datadir}/info/dir %{_datadir}/info/%{name}.info.gz %changelog +* Tue Apr 30 2024 Deyuan Fan - 2.21-16 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: fix:which fails for long path + * Mon Jun 20 2022 yangzhao - 2.21-15 - Type: enhancement - ID: NA