Compare commits

...

No commits in common. "imports/c8s/which-2.21-14.el8" and "c8" have entirely different histories.

3 changed files with 93 additions and 14 deletions

View File

@ -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 <stdio.h>
#include <ctype.h>
+#include <limits.h>
#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;

View File

@ -1,18 +1,28 @@
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh
_declare="declare -f"
_opt="-f"
_shell="$(basename $SHELL)"
case "$(basename $(readlink /proc/$$/exe))" in
*ksh*)
which_declare=""
which_opt=""
;;
zsh)
which_declare="typeset -f"
which_opt=""
;;
bash|sh)
which_declare="declare -f"
which_opt="-f"
;;
*)
which_declare=""
which_opt=""
;;
esac
if [ "$_shell" = "ksh" ] || [ "$_shell" = "mksh" ] || [ "$_shell" = "zsh" ] ; then
_declare="typeset -f"
_opt=""
fi
which ()
{
(alias; eval ${_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
function which {
(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
export ${_opt} which
export which_declare
export ${which_opt} which

View File

@ -1,15 +1,17 @@
Summary: Displays where a particular program in your path is located
Name: which
Version: 2.21
Release: 14%{?dist}
Release: 20%{?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-coverity.patch
Patch2: which-2.21-path_max.patch
Url: https://savannah.gnu.org/projects/which/
BuildRequires: gcc
Requires: coreutils
BuildRequires: gcc
BuildRequires: readline-devel
%description
@ -20,6 +22,7 @@ the specified program is in your PATH.
%setup -q
%patch0 -p1 -b .coverity
%patch1 -p1 -b .coverity2
%patch2 -p1 -b .path_max
%build
%configure
@ -41,6 +44,26 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%{_mandir}/man1/which.1*
%changelog
* Wed Mar 22 2023 Than Ngo <than@redhat.com> - 2.21-20
- Related: #2140566, bring test over from Brew dist-git
* Tue Mar 21 2023 Than Ngo <than@redhat.com> - 2.21-19
- Resolves: #2140566, which fails for long path
* Mon Apr 11 2022 Than Ngo <than@redhat.com> - 2.21-18
- Resolves: #2044450 - custom profile generates shell error
* Thu Nov 25 2021 Than Ngo <than@redhat.com> - 2.21-17
- Resolves: #2025709, check shell correctly
- Resolves: #2009547, which treats function contents as aliases when parsing ksh
* Wed May 05 2021 Than Ngo <than@redhat.com> - 2.21-16
- Related: #1940468, fixed unbound variable
* Fri Apr 30 2021 Than Ngo <than@redhat.com> - 2.21-15
- Related: #1940468, fix error when the user runs which in bash with strict bash environment
* Tue Mar 23 2021 Than Ngo <than@redhat.com> - 2.21-14
- Related: #1940468, fix regression if SHELL=zsh