less: bump version, remove old version (#10327)

* less: bump version, remove old version

Fixes CVE-2022-46663

* less: use B_USER_VAR_DIRECTORY for the history file

It now uses XDG_STATE_DIR by default, the find_directory based code path is
only used as fallback instead of `~/.local/state` if that isn't defined.
XDG_STATE_DIR is defined since hrev57631 and defaults to B_USER_VAR_DIRECTORY.
This commit is contained in:
Joachim Mairböck
2024-04-12 19:11:17 +02:00
committed by GitHub
parent a85b832369
commit 4669db151e
5 changed files with 168 additions and 534 deletions

View File

@@ -1,65 +0,0 @@
SUMMARY="A free, open-source file pager"
DESCRIPTION="GNU 'less' is a program similar to 'more', but which allows \
backward movement in the file as well as forward movement. Also, 'less' \
does not have to read the entire input file before starting, so with \
large input files it starts up faster than text editors like 'vi'.
Less uses 'termcap' (or 'terminfo' on some systems), so it can run on a \
variety of terminals. There is even limited support for hardcopy terminals."
HOMEPAGE="http://www.greenwoodsoftware.com/less/"
COPYRIGHT="1984-2015 Mark Nudelman"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="http://www.greenwoodsoftware.com/less/less-$portVersion.tar.gz"
CHECKSUM_SHA256="f3dc8455cb0b2b66e0c6b816c00197a71bf6d1787078adeee0bcf2aea4b12706"
PATCHES="less-$portVersion.patchset"
ADDITIONAL_FILES="sysless.in"
ARCHITECTURES="all"
GLOBAL_WRITABLE_FILES="
settings/etc/sysless.src keep-old
settings/etc/sysless keep-old
"
PROVIDES="
less = $portVersion
cmd:less
cmd:lessecho
cmd:lesskey
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libncurses$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libncurses$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:aclocal
cmd:autoconf
cmd:gcc$secondaryArchSuffix
cmd:ld$secondaryArchSuffix
cmd:make
"
BUILD()
{
autoconf
runConfigure ./configure --with-editor=nano \
--sysconfdir=$settingsDir/etc
make
}
INSTALL()
{
make install
syslessDir=$settingsDir/etc
mkdir $syslessDir
cp "$portDir/additional-files/sysless.in" \
"$syslessDir/sysless.src"
$binDir/lesskey -o "$syslessDir/sysless" \
"$syslessDir/sysless.src"
}

View File

@@ -6,11 +6,11 @@ large input files it starts up faster than text editors like 'vi'.
Less uses 'termcap' (or 'terminfo' on some systems), so it can run on a \
variety of terminals. There is even limited support for hardcopy terminals."
HOMEPAGE="http://www.greenwoodsoftware.com/less/"
COPYRIGHT="1984-2021 Mark Nudelman"
COPYRIGHT="1984-2023 Mark Nudelman"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="http://www.greenwoodsoftware.com/less/less-$portVersion.tar.gz"
CHECKSUM_SHA256="ce34b47caf20a99740672bf560fc48d5d663c5e78e67bc254e616b9537d5d83b"
CHECKSUM_SHA256="2911b5432c836fa084c8a2e68f6cd6312372c026a58faaa98862731c8b6052e8"
PATCHES="less-$portVersion.patchset"
ADDITIONAL_FILES="sysless.in"

View File

@@ -1,329 +0,0 @@
From ffa25716611e1af39cf5cd4f6a1248d208040374 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 3 Sep 2014 15:09:24 +0000
Subject: haiku patch
diff --git a/cmdbuf.c b/cmdbuf.c
index 69d7414..6686cdf 100644
--- a/cmdbuf.c
+++ b/cmdbuf.c
@@ -74,16 +74,16 @@ struct mlist
/*
* These are the various command histories that exist.
*/
-struct mlist mlist_search =
+struct mlist mlist_search =
{ &mlist_search, &mlist_search, &mlist_search, NULL, 0 };
public void * constant ml_search = (void *) &mlist_search;
-struct mlist mlist_examine =
+struct mlist mlist_examine =
{ &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 };
public void * constant ml_examine = (void *) &mlist_examine;
#if SHELL_ESCAPE || PIPEC
-struct mlist mlist_shell =
+struct mlist mlist_shell =
{ &mlist_shell, &mlist_shell, &mlist_shell, NULL, 0 };
public void * constant ml_shell = (void *) &mlist_shell;
#endif
@@ -420,7 +420,7 @@ cmd_right()
char *pr;
char *ncp;
int width;
-
+
if (*cp == '\0')
{
/* Already at the end of the line. */
@@ -454,7 +454,7 @@ cmd_left()
{
char *ncp;
int width, bswidth;
-
+
if (cp <= cmdbuf)
{
/* Already at the beginning of the line */
@@ -485,14 +485,14 @@ cmd_ichar(cs, clen)
int clen;
{
char *s;
-
+
if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1)
{
/* No room in the command buffer for another char. */
bell();
return (CC_ERROR);
}
-
+
/*
* Make room for the new character (shift the tail of the buffer right).
*/
@@ -552,7 +552,7 @@ cmd_erase()
*/
updown_match = -1;
cmd_repaint(cp);
-
+
/*
* We say that erasing the entire command string causes us
* to abort the current command, if CF_QUIT_ON_ERASE is set.
@@ -689,7 +689,7 @@ cmd_updown(action)
{
char *s;
struct mlist *ml;
-
+
if (curr_mlist == NULL)
{
/*
@@ -754,7 +754,7 @@ cmd_addhist(mlist, cmd, modified)
{
#if CMD_HISTORY
struct mlist *ml;
-
+
/*
* Don't save a trivial command.
*/
@@ -826,7 +826,7 @@ cmd_edit(c)
#else
#define not_in_completion()
#endif
-
+
/*
* See if the char is indeed a line-editing command.
*/
@@ -937,7 +937,7 @@ cmd_istr(str)
char *s;
int action;
char *endline = str + strlen(str);
-
+
for (s = str; *s != '\0'; )
{
char *os = s;
@@ -969,7 +969,7 @@ delimit_word()
char *esc = get_meta_escape();
int esclen = (int) strlen(esc);
#endif
-
+
/*
* Move cursor to end of word.
*/
@@ -1042,7 +1042,7 @@ delimit_word()
/*
* Set things up to enter completion mode.
- * Expand the word under the cursor into a list of filenames
+ * Expand the word under the cursor into a list of filenames
* which start with that word, and set tk_text to that list.
*/
static void
@@ -1050,7 +1050,7 @@ init_compl()
{
char *word;
char c;
-
+
/*
* Get rid of any previous tk_text.
*/
@@ -1139,8 +1139,8 @@ cmd_complete(action)
if (!in_completion || action == EC_EXPAND)
{
/*
- * Expand the word under the cursor and
- * use the first word in the expansion
+ * Expand the word under the cursor and
+ * use the first word in the expansion
* (or the entire expansion if we're doing EC_EXPAND).
*/
init_compl();
@@ -1172,13 +1172,13 @@ cmd_complete(action)
*/
tk_trial = next_compl(action, tk_trial);
}
-
+
/*
* Remove the original word, or the previous trial completion.
*/
while (cp > tk_ipoint)
(void) cmd_erase();
-
+
if (tk_trial == NULL)
{
/*
@@ -1209,9 +1209,9 @@ cmd_complete(action)
goto fail;
}
}
-
+
return (CC_OK);
-
+
fail:
in_completion = 0;
bell();
@@ -1292,7 +1292,7 @@ cmd_char(c)
literal = 0;
return (cmd_ichar(cmd_mbc_buf, len));
}
-
+
/*
* See if it is a line-editing character.
*/
@@ -1308,7 +1308,7 @@ cmd_char(c)
break;
}
}
-
+
/*
* Insert the char into the command buffer.
*/
@@ -1378,10 +1378,14 @@ mlist_size(ml)
static char *
histfile_name()
{
+#ifdef __HAIKU__
+ char home[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+#else
char *home;
+#endif
char *name;
int len;
-
+
/* See if filename is explicitly specified by $LESSHISTFILE. */
name = lgetenv("LESSHISTFILE");
if (name != NULL && *name != '\0')
@@ -1396,6 +1400,13 @@ histfile_name()
if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0)
return (NULL);
+#ifdef __HAIKU__
+ {
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, home, sizeof(home)) != B_OK)
+ return (NULL);
+ }
+#else
/* Otherwise, file is in $HOME. */
home = lgetenv("HOME");
if (home == NULL || *home == '\0')
@@ -1406,6 +1417,7 @@ histfile_name()
#endif
return (NULL);
}
+#endif
len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2);
name = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
diff --git a/configure.ac b/configure.ac
index 4ac9a35..d9e299a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -596,10 +596,17 @@ AH_TOP([
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
-#define LESSKEYFILE ".less"
-#define LESSKEYFILE_SYS SYSDIR "/sysless"
-#define DEF_LESSKEYINFILE ".lesskey"
-#define LESSHISTFILE ".lesshst"
+#ifdef __HAIKU__
+# define LESSKEYFILE "less"
+# define LESSKEYFILE_SYS SYSDIR "/sysless"
+# define DEF_LESSKEYINFILE "lesskey"
+# define LESSHISTFILE "lesshst"
+#else
+# define LESSKEYFILE ".less"
+# define LESSKEYFILE_SYS SYSDIR "/sysless"
+# define DEF_LESSKEYINFILE ".lesskey"
+# define LESSHISTFILE ".lesshst"
+#endif
/* Settings always true on Unix. */
diff --git a/filename.c b/filename.c
index 9631f1c..dc13a96 100644
--- a/filename.c
+++ b/filename.c
@@ -266,12 +266,23 @@ homefile(filename)
{
register char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = dirfile(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
/*
* Try $HOME/filename.
*/
pathname = dirfile(lgetenv("HOME"), filename);
if (pathname != NULL)
return (pathname);
+#endif
#if OS2
/*
* Try $INIT/filename.
diff --git a/less.h b/less.h
index f57fb1e..17159dd 100644
--- a/less.h
+++ b/less.h
@@ -93,6 +93,11 @@
#include <floss.h>
#endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <StorageDefs.h>
+#endif
+
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
diff --git a/lesskey.c b/lesskey.c
index 298748b..fa4c05b 100644
--- a/lesskey.c
+++ b/lesskey.c
@@ -246,8 +246,19 @@ homefile(filename)
char *p;
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = mkpathname(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
if ((p = getenv("HOME")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
+#endif
#if OS2
else if ((p = getenv("INIT")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
--
2.2.2

View File

@@ -1,138 +0,0 @@
From f37c832e4c028a392e04ef0e0731d98e39fe7570 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 29 Jun 2017 17:06:55 +0200
Subject: import fix from previous version
diff --git a/cmdbuf.c b/cmdbuf.c
index 0648aec..7e7cf68 100644
--- a/cmdbuf.c
+++ b/cmdbuf.c
@@ -1401,7 +1401,11 @@ mlist_size(ml)
static char *
histfile_name(VOID_PARAM)
{
+#ifdef __HAIKU__
+ char home[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+#else
char *home;
+#endif
char *name;
int len;
@@ -1419,6 +1423,13 @@ histfile_name(VOID_PARAM)
if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0)
return (NULL);
+#ifdef __HAIKU__
+ {
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, home, sizeof(home)) != B_OK)
+ return (NULL);
+ }
+#else
/* Otherwise, file is in $HOME. */
home = lgetenv("HOME");
if (isnullenv(home))
@@ -1429,6 +1440,7 @@ histfile_name(VOID_PARAM)
#endif
return (NULL);
}
+#endif
len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2);
name = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
diff --git a/configure.ac b/configure.ac
index 7a69398..bf9f78e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -610,11 +610,17 @@ AH_TOP([
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
+#ifdef __HAIKU__
+# define LESSKEYFILE "less"
+# define LESSKEYFILE_SYS SYSDIR "/sysless"
+# define DEF_LESSKEYINFILE "lesskey"
+# define LESSHISTFILE "lesshst"
+#else
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
-
+#endif
/* Settings always true on Unix. */
diff --git a/filename.c b/filename.c
index 7c3ccd2..c813a68 100644
--- a/filename.c
+++ b/filename.c
@@ -259,12 +259,23 @@ homefile(filename)
{
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = dirfile(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
/*
* Try $HOME/filename.
*/
pathname = dirfile(lgetenv("HOME"), filename);
if (pathname != NULL)
return (pathname);
+#endif
#if OS2
/*
* Try $INIT/filename.
diff --git a/less.h b/less.h
index 7ec58c3..75b5516 100644
--- a/less.h
+++ b/less.h
@@ -100,6 +100,11 @@
#include <floss.h>
#endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <StorageDefs.h>
+#endif
+
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
diff --git a/lesskey.c b/lesskey.c
index 96a4462..912010c 100644
--- a/lesskey.c
+++ b/lesskey.c
@@ -250,8 +250,19 @@ homefile(filename)
char *p;
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = mkpathname(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
if ((p = getenv("HOME")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
+#endif
#if OS2
else if ((p = getenv("INIT")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
--
2.19.1

View File

@@ -0,0 +1,166 @@
From 42981d3f93f7163f1b2f29c6931e74bc008e9285 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 29 Jun 2017 17:06:55 +0200
Subject: import fix from previous version
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Joachim Mairböck <j.mairboeck@gmail.com>
diff --git a/cmdbuf.c b/cmdbuf.c
index c813283..dac4c98 100644
--- a/cmdbuf.c
+++ b/cmdbuf.c
@@ -1356,12 +1356,19 @@ static char * histfile_find(int must_exist)
name = dirfile(lgetenv("XDG_STATE_HOME"), &LESSHISTFILE[1], must_exist);
if (name == NULL)
{
+#ifdef __HAIKU__
+ char dir[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_VAR_DIRECTORY, volume, true, dir, sizeof(dir)) == B_OK)
+ name = dirfile(dir, &LESSHISTFILE[1], must_exist);
+#else
char *dir = dirfile(home, ".local/state", 1);
if (dir != NULL)
{
name = dirfile(dir, &LESSHISTFILE[1], must_exist);
free(dir);
}
+#endif
}
if (name == NULL)
name = dirfile(lgetenv("XDG_DATA_HOME"), &LESSHISTFILE[1], must_exist);
diff --git a/configure.ac b/configure.ac
index 37dc496..f4d003b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -582,9 +582,15 @@ AH_TOP([
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
+#ifdef __HAIKU__
+# define LESSKEYFILE "less"
+# define LESSKEYFILE_SYS SYSDIR "/sysless"
+# define DEF_LESSKEYINFILE "lesskey"
+#else
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
+#endif
#define LESSKEYINFILE_SYS SYSDIR "/syslesskey"
#define LESSHISTFILE ".lesshst"
diff --git a/filename.c b/filename.c
index a8726dc..8efcccb 100644
--- a/filename.c
+++ b/filename.c
@@ -253,10 +253,21 @@ public char * homefile(char *filename)
{
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = dirfile(path, filename, 1);
+ if (pathname != NULL)
+ return (pathname);
+#else
/* Try $HOME/filename. */
pathname = dirfile(lgetenv("HOME"), filename, 1);
if (pathname != NULL)
return (pathname);
+#endif
#if OS2
/* Try $INIT/filename. */
pathname = dirfile(lgetenv("INIT"), filename, 1);
diff --git a/less.h b/less.h
index 2ba8c35..080daaf 100644
--- a/less.h
+++ b/less.h
@@ -111,6 +111,11 @@ typedef unsigned long uintmax;
#include <floss.h>
#endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <StorageDefs.h>
+#endif
+
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
diff --git a/lesskey.c b/lesskey.c
index 61311c7..14b6c2c 100644
--- a/lesskey.c
+++ b/lesskey.c
@@ -87,6 +87,11 @@
#include "lesskey.h"
#include "cmd.h"
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <StorageDefs.h>
+#endif
+
char fileheader[] = {
C0_LESSKEY_MAGIC,
C1_LESSKEY_MAGIC,
@@ -159,8 +164,19 @@ char * homefile(char *filename)
char *p;
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = mkpathname(path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
if ((p = getenv("HOME")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
+#endif
#if OS2
else if ((p = getenv("INIT")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
--
2.43.2
From 52be1da870e69f51ccd06b59683285381487bed3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= <j.mairboeck@gmail.com>
Date: Fri, 12 Apr 2024 16:35:13 +0200
Subject: gcc2 build fix
diff --git a/command.c b/command.c
index f5ee7ed..e38be19 100644
--- a/command.c
+++ b/command.c
@@ -713,6 +713,7 @@ static int mca_char(int c)
/* Incremental search: do a search after every input char. */
int st = (search_type & (SRCH_FORW|SRCH_BACK|SRCH_NO_MATCH|SRCH_NO_REGEX|SRCH_NO_MOVE|SRCH_WRAP|SRCH_SUBSEARCH_ALL));
char *pattern = get_cmdbuf();
+ int save_updown_match;
if (pattern == NULL)
return (MCA_MORE);
/*
@@ -720,7 +721,7 @@ static int mca_char(int c)
* reinits it. That breaks history scrolling.
* {{ This is ugly. mca_search probably shouldn't call set_mlist. }}
*/
- int save_updown_match = updown_match;
+ save_updown_match = updown_match;
cmd_exec();
if (*pattern == '\0')
{
--
2.43.2