Resolves: #2181974, which fails for long path

This commit is contained in:
Than Ngo 2023-03-27 16:38:45 +02:00 committed by Stepan Oksanichenko
parent 603e739e09
commit 56768f7cd6
3 changed files with 54 additions and 1 deletions

1
.which.metadata Normal file
View File

@ -0,0 +1 @@
6b6bec3d2b3d4661c164feb81b9b1d22d1359ded which-2.21.tar.gz

46
which-2.21-path_max.patch Normal file
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,12 +1,14 @@
Summary: Displays where a particular program in your path is located Summary: Displays where a particular program in your path is located
Name: which Name: which
Version: 2.21 Version: 2.21
Release: 28%{?dist} Release: 29%{?dist}
License: GPLv3 License: GPLv3
Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz
Source1: which2.sh Source1: which2.sh
Source2: which2.csh Source2: which2.csh
Patch0: which-2.21-coverity-fixes.patch Patch0: which-2.21-coverity-fixes.patch
Patch1: which-2.21-path_max.patch
Url: https://savannah.gnu.org/projects/which/ Url: https://savannah.gnu.org/projects/which/
BuildRequires: make BuildRequires: make
BuildRequires: gcc BuildRequires: gcc
@ -19,6 +21,7 @@ the specified program is in your PATH.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .coverity %patch0 -p1 -b .coverity
%patch1 -p1 -b .path_max
%build %build
%configure %configure
@ -40,6 +43,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%{_mandir}/man1/which.1* %{_mandir}/man1/which.1*
%changelog %changelog
* Mon Mar 27 2023 Than Ngo <than@redhat.com> - 2.21-29
- Resolves: #2181974, which fails for long path
* Fri Apr 15 2022 Than Ngo <than@redhat.com> - 2.21-28 * Fri Apr 15 2022 Than Ngo <than@redhat.com> - 2.21-28
- Resolves: #2050996, error on login when using ksh as the default shell - Resolves: #2050996, error on login when using ksh as the default shell