which fails for long path
This commit is contained in:
parent
60c3d4bb4e
commit
1124b8285f
59
0001-which-fails-for-long-path.patch
Normal file
59
0001-which-fails-for-long-path.patch
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
From 77420bf2e35444f348b19e0acaf1f77bb4ed3f76 Mon Sep 17 00:00:00 2001
|
||||||
|
From: fandeyuan <fandeyuan@kylinos.cn>
|
||||||
|
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 <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, 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
|
||||||
|
|
||||||
10
which.spec
10
which.spec
@ -1,11 +1,13 @@
|
|||||||
Name: which
|
Name: which
|
||||||
Version: 2.21
|
Version: 2.21
|
||||||
Release: 15
|
Release: 16
|
||||||
Summary: Show the full path of commands
|
Summary: Show the full path of commands
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
URL: https://savannah.gnu.org/projects/which/
|
URL: https://savannah.gnu.org/projects/which/
|
||||||
Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz
|
Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
|
Patch1: 0001-which-fails-for-long-path.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -40,6 +42,12 @@ rm -f %{buildroot}/%{_datadir}/info/dir
|
|||||||
%{_datadir}/info/%{name}.info.gz
|
%{_datadir}/info/%{name}.info.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 30 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 2.21-16
|
||||||
|
- Type: bugfix
|
||||||
|
- ID: NA
|
||||||
|
- SUG: NA
|
||||||
|
- DESC: fix:which fails for long path
|
||||||
|
|
||||||
* Mon Jun 20 2022 yangzhao <yangzhao1@kylinos.cn> - 2.21-15
|
* Mon Jun 20 2022 yangzhao <yangzhao1@kylinos.cn> - 2.21-15
|
||||||
- Type: enhancement
|
- Type: enhancement
|
||||||
- ID: NA
|
- ID: NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user