From 9a3c8653505ecfae0c5b44ca9d97b43b98aa4ba0 Mon Sep 17 00:00:00 2001 From: Than Ngo Date: Mon, 7 Nov 2022 16:29:33 +0100 Subject: [PATCH] which fails for long path --- which-2.21-path_max.patch | 46 +++++++++++++++++++++++++++++++++++++++ which.spec | 11 ++++++---- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 which-2.21-path_max.patch diff --git a/which-2.21-path_max.patch b/which-2.21-path_max.patch new file mode 100644 index 0000000..eec9958 --- /dev/null +++ b/which-2.21-path_max.patch @@ -0,0 +1,46 @@ +diff -up which-2.21/which.c.me which-2.21/which.c +--- which-2.21/which.c.me 2022-11-07 13:11:03.580798950 +0100 ++++ which-2.21/which.c 2022-11-07 15:45:41.366085798 +0100 +@@ -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, + 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; +@@ -163,7 +168,7 @@ static char *find_command_in_path(const + return (found); + } + +-static char cwd[256]; ++static char cwd[PATH_MAX]; + static size_t cwdlen; + + static void get_current_working_directory(void) +@@ -195,7 +200,7 @@ static void get_current_working_director + + static char *path_clean_up(const char *path) + { +- static char result[256]; ++ static char result[PATH_MAX]; + + const char *p1 = path; + char *p2 = result; diff --git a/which.spec b/which.spec index c820dac..07fe94b 100644 --- a/which.spec +++ b/which.spec @@ -3,12 +3,13 @@ Summary: Displays where a particular program in your path is located Name: which Version: 2.21 -Release: 35%{?dist} +Release: 36%{?dist} License: GPLv3 Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz Source1: which2.sh Source2: which2.csh Patch0: which-2.21-coverity-fixes.patch +Patch1: which-2.21-path_max.patch Url: https://savannah.gnu.org/projects/which/ Requires: coreutils BuildRequires: make @@ -20,9 +21,8 @@ The which command shows the full pathname of a specified program, if the specified program is in your PATH. %prep -%setup -q -%patch0 -p1 -b .coverity - +%autosetup -p1 + %build %configure %make_build @@ -47,6 +47,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %{_mandir}/man1/which.1* %changelog +* Mon Nov 07 2022 Than Ngo - 2.21-36 +- which fails for long path + * Fri Aug 05 2022 Than Ngo - 2.21-35 - disable which2 alias and function by default as it caused more problems than benefits