Repository navigation
Fixed: "cd on quit": cmd history not saved, 'cfgpath' corrupted; - #2180
Conversation
When invoked with 'outfile == NULL', write_lastdir() overwrites the
global var 'cfgpath' with the full pathname of the '.lastd' file for
the "cd on quit" functionality;
Unfortunately, that variable is used at a later point during the
program exit process, resulting in an incorrect pathname for the
'.history' file, causing the history file not to be written.
This commit:
* Uses a buffer ('g_buf') other than 'cfgpath' to hold the
constructed pathname for the '.lastd' file;
* Simplifies the logic deciding which 'const char *' to pass to
'open()';
| int fd = open(outfile | ||
| ? (tilde ? g_buf : outfile) | ||
| : cfgpath, O_CREAT | O_WRONLY | O_TRUNC, S_IWUSR | S_IRUSR); | ||
| int fd = open(use_g_buf ? g_buf : outfile, |
There was a problem hiding this comment.
Hi, @jarun. Thank you for looking at this.
I've reviewed the tool's output and it looks to me as if these are all pre-existing issues, and none of the modifications I've done have (should have) made a difference with regards to accepting "user input" (environment variables in this case) and using that as input for file access functions. That's the whole point of having environment variables like NNN_TMPFILE, where the user is explicitly given the ability to control which file(s) are accessed by the program.
I'd be curious to see the same tool checks applied to the code before my suggested changes. I strongly suspect those "security vulnerabilities" are present upstream.
Would it be possible to run the checks against master just to see what the differences are? (to establish a baseline, as they say).
Thank you :-)
|
Thank you! |
When invoked with
outfile == NULL,write_lastdir()overwrites theglobal var
cfgpathwith the full pathname of the.lastdfile forthe "cd on quit" functionality;
Unfortunately, that variable is used at a later point during the
program exit process, resulting in an incorrect pathname for the
.historyfile, causing the history file not to be written.This commit:
Uses a buffer (
g_buf) other thancfgpathto hold the constructed pathname for the.lastdfile;Simplifies the logic deciding which
const char *value to pass toopen();