Do not assume PATH_MAX is defined

This commit is contained in:
baiguo 2024-06-21 09:36:16 +08:00
parent 157266350e
commit ae4631cc17
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From eea6fbc196872eeca6f02fcfba298f3e1bb62880 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Thu, 11 Jan 2024 02:18:07 +0100
Subject: [PATCH] Do not assume PATH_MAX is defined
---
filename.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/filename.c b/filename.c
index eb6b16c..f17e3ba 100644
--- a/filename.c
+++ b/filename.c
@@ -829,10 +829,26 @@ lglob(filename)
lrealpath(path)
char *path;
{
+
#if HAVE_REALPATH
+ /*
+ * Not all systems support the POSIX.1-2008 realpath() behavior
+ * of allocating when passing a NULL argument. And PATH_MAX is
+ * not required to be defined, or might contain an exceedingly
+ * big value. We assume that if it is not defined (such as on
+ * GNU/Hurd), then realpath() accepts NULL.
+ */
+#ifndef PATH_MAX
+ char *rpath;
+
+ rpath = realpath(path, NULL);
+ if (rpath != NULL)
+ return (rpath);
+#else
char rpath[PATH_MAX];
if (realpath(path, rpath) != NULL)
return (save(rpath));
+#endif
#endif
return (save(path));
}
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: less
Version: 590
Release: 5
Release: 6
Summary: Less is a pager that displays text files.
License: GPLv3+ or BSD
URL: http://www.greenwoodsoftware.com/less
@ -13,6 +13,7 @@ Patch4: backport-Undelete-usleep-nanosleep-ttyname-poll.patch
Patch5: backport-Some-constifying.patch
Patch6: backport-Implement-osc8_open.patch
Patch7: backport-CVE-2024-32487.patch
Patch8: backport-Do-not-assume-PATH_MAX-is-defined.patch
BuildRequires: git gcc make ncurses-devel autoconf automake libtool
@ -51,6 +52,9 @@ autoreconf -ivf
%{_mandir}/man1/*
%changelog
* Fri Jun 21 2024 baiguo <baiguo@kylinos.cn> - 590-6
- Do not assume PATH_MAX is defined
* Mon Apr 22 2024 wangjiang <wangjiang37@h-partners.com> - 590-5
- fix CVE-2024-32487