mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-23 15:09:24 -05:00
cmdline.c: free cmdline_password whenever it's reset.
If you provided two -pw or -pwfile arguments on the same command line, the first password could be left in memory uncleared. Spotted by Coverity.
This commit is contained in:
parent
af6a19e962
commit
6344e40e3f
10
cmdline.c
10
cmdline.c
@ -585,6 +585,11 @@ int cmdline_process_param(const char *p, char *value,
|
|||||||
cmdline_error("the -pw option can only be used with the "
|
cmdline_error("the -pw option can only be used with the "
|
||||||
"SSH protocol");
|
"SSH protocol");
|
||||||
else {
|
else {
|
||||||
|
if (cmdline_password) {
|
||||||
|
smemclr(cmdline_password, strlen(cmdline_password));
|
||||||
|
sfree(cmdline_password);
|
||||||
|
}
|
||||||
|
|
||||||
cmdline_password = dupstr(value);
|
cmdline_password = dupstr(value);
|
||||||
/* Assuming that `value' is directly from argv, make a good faith
|
/* Assuming that `value' is directly from argv, make a good faith
|
||||||
* attempt to trample it, to stop it showing up in `ps' output
|
* attempt to trample it, to stop it showing up in `ps' output
|
||||||
@ -608,6 +613,11 @@ int cmdline_process_param(const char *p, char *value,
|
|||||||
if (!fp) {
|
if (!fp) {
|
||||||
cmdline_error("unable to open password file '%s'", value);
|
cmdline_error("unable to open password file '%s'", value);
|
||||||
} else {
|
} else {
|
||||||
|
if (cmdline_password) {
|
||||||
|
smemclr(cmdline_password, strlen(cmdline_password));
|
||||||
|
sfree(cmdline_password);
|
||||||
|
}
|
||||||
|
|
||||||
cmdline_password = chomp(fgetline(fp));
|
cmdline_password = chomp(fgetline(fp));
|
||||||
if (!cmdline_password) {
|
if (!cmdline_password) {
|
||||||
cmdline_error("unable to read a password from file '%s'",
|
cmdline_error("unable to read a password from file '%s'",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user