From: Douglas Bagnall Date: Wed, 5 Feb 2025 03:47:39 +0000 (+1300) Subject: utils/smbtree: do not crash with no password (-N) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18928f524c41f6584925fc0313f0e5405e9ceb3d;p=thirdparty%2Fsamba.git utils/smbtree: do not crash with no password (-N) BUG: https://bugzilla.samba.org/show_bug.cgi?id=15170 Signed-off-by: Douglas Bagnall Reviewed-by: Jennifer Sutton --- diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 26363fd58ed..4e178113e1a 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -47,6 +47,7 @@ static void get_auth_data_with_context_fn( { struct cli_credentials *creds = samba_cmdline_get_creds(); size_t len; + const char *pwd = NULL; len = strlcpy(domain, cli_credentials_get_domain(creds), domain_len); if ((int)len >= domain_len) { @@ -57,8 +58,12 @@ static void get_auth_data_with_context_fn( if ((int)len >= user_len) { return; } - len = strlcpy( - password, cli_credentials_get_password(creds), password_len); + pwd = cli_credentials_get_password(creds); + if (pwd == NULL) { + pwd = ""; + } + + len = strlcpy(password, pwd, password_len); if ((int)len >= password_len) { /* pointless, but what can you do... */ return;