diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2021-10-09 15:27:20 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2021-10-09 15:27:20 +0000 |
commit | d001a943ebb443c9fda14de8bf29b101ebd2ddff (patch) | |
tree | 8415aa91c5c02bc38ddedfc0c984e21667637a6c /usr.bin | |
parent | 17ed06b88d3bbe9dc4af4439d247200c26c33785 (diff) |
Merge upstream bug fixes
- Switch http to https for upstream URL
- Fix buffer sizes and lesskey parser functions
- Fix integer overflow in bracket match function
- Fix prompt hiding feature (CTRL + P)
ok deraadt, millert
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/less/brac.c | 2 | ||||
-rw-r--r-- | usr.bin/less/command.c | 7 | ||||
-rw-r--r-- | usr.bin/less/decode.c | 11 | ||||
-rw-r--r-- | usr.bin/less/optfunc.c | 4 | ||||
-rw-r--r-- | usr.bin/less/option.c | 2 |
5 files changed, 20 insertions, 6 deletions
diff --git a/usr.bin/less/brac.c b/usr.bin/less/brac.c index b27ea6162f5..0540e41de57 100644 --- a/usr.bin/less/brac.c +++ b/usr.bin/less/brac.c @@ -75,6 +75,8 @@ match_brac(int obrac, int cbrac, int forwdir, int n) nest = 0; while ((c = (*chget)()) != EOI) { if (c == obrac) { + if (nest == INT_MAX) + break; nest++; } else if (c == cbrac && --nest < 0) { /* diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c index 4a90d74d185..4fc19d949f7 100644 --- a/usr.bin/less/command.c +++ b/usr.bin/less/command.c @@ -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'): diff --git a/usr.bin/less/decode.c b/usr.bin/less/decode.c index 67496d89659..4846e0cb408 100644 --- a/usr.bin/less/decode.c +++ b/usr.bin/less/decode.c @@ -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 sysvar) 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(&p); + if (n < 0 || p + n >= end) + return (-1); add_fcmd_table(p, n); p += n; break; case EDIT_SECTION: n = gint(&p); + if (n < 0 || p + n >= end) + return (-1); add_ecmd_table(p, n); p += n; break; case VAR_SECTION: n = gint(&p); + if (n < 0 || p + n >= end) + return (-1); add_var_table((sysvar) ? &list_sysvar_tables : &list_var_tables, p, n); p += n; @@ -663,7 +671,8 @@ lesskey(char *filename, int sysvar) * Figure out if this is an old-style (before version 241) * or new-style lesskey file format. */ - if (buf[0] != C0_LESSKEY_MAGIC || buf[1] != C1_LESSKEY_MAGIC || + if (len < 4 || + buf[0] != C0_LESSKEY_MAGIC || buf[1] != C1_LESSKEY_MAGIC || buf[2] != C2_LESSKEY_MAGIC || buf[3] != C3_LESSKEY_MAGIC) return (old_lesskey(buf, (int)len)); return (new_lesskey(buf, (int)len, sysvar)); diff --git a/usr.bin/less/optfunc.c b/usr.bin/less/optfunc.c index 2c0b81f1401..c9e6490f1d1 100644 --- a/usr.bin/less/optfunc.c +++ b/usr.bin/less/optfunc.c @@ -420,7 +420,7 @@ opt__V(int type, char *s) putstr("to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); - putstr("Homepage: http://www.greenwoodsoftware.com/less\n"); + putstr("Homepage: https://www.greenwoodsoftware.com/less\n"); putstr("\n"); quit(QUIT_OK); break; @@ -436,7 +436,7 @@ opt_x(int type, char *s) extern int tabstops[]; extern int ntabstops; extern int tabdefault; - char tabs[60+(4*TABSTOP_MAX)]; + char tabs[60 + 11 * TABSTOP_MAX]; int i; PARG p; diff --git a/usr.bin/less/option.c b/usr.bin/less/option.c index 7bdda88ad75..fbfefe46700 100644 --- a/usr.bin/less/option.c +++ b/usr.bin/less/option.c @@ -55,7 +55,7 @@ opt_desc(struct loption *o) char * propt(int c) { - static char buf[8]; + static char buf[33]; (void) snprintf(buf, sizeof (buf), "-%s", prchar(c)); return (buf); |