nest = 0;
while ((c = (*chget)()) != EOI) {
if (c == obrac) {
+ if (nest == INT_MAX)
+ break;
nest++;
} else if (c == cbrac && --nest < 0) {
/*
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) {
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'):
new_lesskey(char *buf, int len, int sysvar)
{
char *p;
+ char *end;
int c;
int n;
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;
* 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));
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;
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;
char *
propt(int c)
{
- static char buf[8];
+ static char buf[33];
(void) snprintf(buf, sizeof (buf), "-%s", prchar(c));
return (buf);