Skip to content

Commit

Permalink
Don't read or write history file in secure mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Sep 20, 2021
1 parent d07da71 commit 9eba0da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions NEWS
Expand Up @@ -24,6 +24,8 @@

* Allow option name in -- command to end with '=' in addition to '\n'.

* Don't read or write history file in secure mode.

* Fix display of multibyte and double-width chars in prompt.

* Fix ESC-BACKSPACE command when BACKSPACE key does not send 0x08.
Expand All @@ -32,6 +34,10 @@

* Fix bug when empty file is modified while viewing it.

* Fix bug when parsing a malformed lesskey file.

* Fix buffer overflow when invoking lessecho with more than 63 -m/-n options.

======================================================================

Major changes between "less" versions 581 and 590
Expand Down
9 changes: 6 additions & 3 deletions cmdbuf.c
Expand Up @@ -24,6 +24,7 @@ extern int sc_width;
extern int utf_mode;
extern int no_hist_dups;
extern int marks_modified;
extern int secure;

static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
static int cmd_col; /* Current column of the cursor */
Expand Down Expand Up @@ -1524,6 +1525,8 @@ read_cmdhist(action, uparam, skip_search, skip_shell)
int skip_search;
int skip_shell;
{
if (secure)
return;
read_cmdhist2(action, uparam, skip_search, skip_shell);
(*action)(uparam, NULL, NULL); /* signal end of file */
}
Expand Down Expand Up @@ -1673,6 +1676,7 @@ make_file_private(f)
/*
* Does the history file need to be updated?
*/
#if CMD_HISTORY
static int
histfile_modified(VOID_PARAM)
{
Expand All @@ -1682,12 +1686,11 @@ histfile_modified(VOID_PARAM)
if (mlist_shell.modified)
return 1;
#endif
#if CMD_HISTORY
if (marks_modified)
return 1;
#endif
return 0;
}
#endif

/*
* Update the .lesshst file.
Expand All @@ -1705,7 +1708,7 @@ save_cmdhist(VOID_PARAM)
FILE *fout = NULL;
int histsize = 0;

if (!histfile_modified())
if (secure || !histfile_modified())
return;
histname = histfile_name(0);
if (histname == NULL)
Expand Down

0 comments on commit 9eba0da

Please sign in to comment.