Hi,
this merges latest bugfixes from upstream to our version of less.
No new features introduced. Upstream commits and issues are linked as
references.
brac.c:
Signed integer overflow with huge files.
https://github.com/gwsw/less/pull/210
https://github.com/gwsw/less/commit/e6eb4c8ddd7f4e7135facad6c30d80886148ca70
command.c:
A prompt should not be shown if explicitly requested to not show one.
Reproducible by entering "-+e" within less. This should
not yield any status output (CTRL + SHIFT + P suppresses the prompt).
https://github.com/gwsw/less/commit/93fee11541b6837a0063e728e60c50da7929924b
decode.c:
Out of boundary accesses and endless loop with user-specified lesskey file
possible (-k option).
https://github.com/gwsw/less/pull/199
https://github.com/gwsw/less/pull/203
https://github.com/gwsw/less/commit/7318ae5ce310fe8a8784a8b0c80132099b11862c
https://github.com/gwsw/less/commit/d07da7152ecc2086809965646e1b8b7a95b6452c
optfunc.c, http to https:
Upstream changed URL to https, we should do the same.
https://github.com/gwsw/less/commit/a8b4980c8403f6f41ef5e534e6b8ad3b919604a3
optfunc.c:
Increase buffer to stay compatible with upstream. Our TABSTOP_MAX is large
enough to prevent overflow of the buffer already, but keep it in sync in
case we reduce TABSTOP_MAX to 32 just like upstream does by default.
https://github.com/gwsw/less/commit/6a860ee977eea7bfa065789ea4319ecab5af703c
option.c:
prchar has a larger buffer than propt uses internally. This does not lead to
an overflow, we could just truncate custom formatter outputs.
https://github.com/gwsw/less/commit/1d95a137938f347c78bdefa91bde6d7e3678bba0
Okay?
Tobias
Index: brac.c
===
RCS file: /cvs/src/usr.bin/less/brac.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 brac.c
--- brac.c 9 Nov 2015 16:39:13 - 1.9
+++ brac.c 9 Oct 2021 10:58:27 -
@@ -75,6 +75,8 @@ match_brac(int obrac, int cbrac, int for
nest = 0;
while ((c = (*chget)()) != EOI) {
if (c == obrac) {
+ if (nest == INT_MAX)
+ break;
nest++;
} else if (c == cbrac && --nest < 0) {
/*
Index: command.c
===
RCS file: /cvs/src/usr.bin/less/command.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 command.c
--- command.c 3 Sep 2019 23:08:42 - 1.32
+++ command.c 9 Oct 2021 10:58:28 -
@@ -264,6 +264,7 @@ is_erase_char(int c)
static int
mca_opt_first_char(int c)
{
+ int no_prompt = (optflag & OPT_NO_PROMPT);
int flag = (optflag & ~OPT_NO_PROMPT);
if (flag == OPT_NO_TOGGLE) {
switch (c) {
@@ -277,12 +278,14 @@ mca_opt_first_char(int c)
switch (c) {
case '+':
/* "-+" = UNSET. */
- optflag = (flag == OPT_UNSET) ? OPT_TOGGLE : OPT_UNSET;
+ optflag = no_prompt |
+ ((flag == OPT_UNSET) ? OPT_TOGGLE : OPT_UNSET);
mca_opt_toggle();
return (MCA_MORE);
case '!':
/* "-!" = SET */
- optflag = (flag == OPT_SET) ? OPT_TOGGLE : OPT_SET;
+ optflag = no_prompt |
+ ((flag == OPT_SET) ? OPT_TOGGLE : OPT_SET);
mca_opt_toggle();
return (MCA_MORE);
case CONTROL('P'):
Index: decode.c
===
RCS file: /cvs/src/usr.bin/less/decode.c,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 decode.c
--- decode.c28 Jun 2019 13:35:01 - 1.19
+++ decode.c9 Oct 2021 10:58:28 -
@@ -563,6 +563,7 @@ static int
new_lesskey(char *buf, int len, int sysvar)
{
char *p;
+ char *end;
int c;
int n;
@@ -575,21 +576,28 @@ new_lesskey(char *buf, int len, int sysv
buf[len-1] != C2_END_LESSKEY_MAGIC)
return (-1);
p = buf + 4;
+ end = buf + len;
for (;;) {
c = *p++;
switch (c) {
case CMD_SECTION:
n = gint();
+ if (n < 0 || p + n >= end)
+ return (-1);
add_fcmd_table(p, n);
p += n;
break;
case EDIT_SECTION:
n = gint();
+ if (n < 0 || p + n >= end)
+ return (-1);
add_ecmd_table(p, n);
p += n;
break;
case VAR_SECTION:
n = gint();
+ if (n < 0 || p + n >= end)
+