1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

cmdline:burn: do not retain false memories

If argv contains a secret option without an '=' (or in the case of
"-U", the username is separated by space), we will get to the
`if (strlen(p) == ulen) { continue; }` without resetting the found
and is_user variables. This *sometimes* has the right effect, because
the next string in argv ought to contain the secret.

But in a case like {"--password", "1234567890"}, where the secret
string is the same length as the option, we *again* take that branch
and the password is not redacted, though the argument after it will be
unless it is also of the same length.

If we always set the flags at the start we avoid this. This makes
things worse in the short term for secrets that are not the same
length as their options, but we'll get to that in another commit soon.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15674

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
This commit is contained in:
Douglas Bagnall 2024-06-27 15:20:27 +12:00 committed by Douglas Bagnall
parent 05128a1f5f
commit 2f6020cf3d

View File

@ -150,6 +150,9 @@ bool samba_cmdline_burn(int argc, char *argv[])
return false; return false;
} }
found = false;
is_user = false;
/* /*
* Take care that this list must be in longest-match * Take care that this list must be in longest-match
* first order * first order
@ -192,8 +195,6 @@ bool samba_cmdline_burn(int argc, char *argv[])
} }
memset_s(p, strlen(p), '\0', strlen(p)); memset_s(p, strlen(p), '\0', strlen(p));
found = false;
is_user = false;
burnt = true; burnt = true;
} }
} }