From: Volker Lendecke Date: Tue, 17 Aug 2021 18:18:45 +0000 (+0200) Subject: rpc_server: Slightly simplify set_user_info_21() X-Git-Tag: ldb-2.5.0~881 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebac118da5b041862af65bbede2bf3bc39a0b27c;p=thirdparty%2Fsamba.git rpc_server: Slightly simplify set_user_info_21() Instead of adding the NULL check to data_blob_talloc_zero() put "out" on the stack. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c index 28000677fc8..b4c72d901b3 100644 --- a/source3/rpc_server/samr/srv_samr_nt.c +++ b/source3/rpc_server/samr/srv_samr_nt.c @@ -4711,7 +4711,11 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21, if (id21->fields_present & SAMR_FIELD_NT_PASSWORD_PRESENT) { if (id21->nt_password_set) { - DATA_BLOB in, out; + DATA_BLOB in = data_blob_const( + id21->nt_owf_password.array, 16); + uint8_t outbuf[16] = { 0, }; + DATA_BLOB out = data_blob_const( + outbuf, sizeof(outbuf)); if ((id21->nt_owf_password.length != 16) || (id21->nt_owf_password.size != 16)) { @@ -4722,9 +4726,6 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21, return NT_STATUS_NO_USER_SESSION_KEY; } - in = data_blob_const(id21->nt_owf_password.array, 16); - out = data_blob_talloc_zero(mem_ctx, 16); - rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT); if (rc != 0) { return gnutls_error_to_ntstatus(rc, @@ -4738,7 +4739,11 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21, if (id21->fields_present & SAMR_FIELD_LM_PASSWORD_PRESENT) { if (id21->lm_password_set) { - DATA_BLOB in, out; + DATA_BLOB in = data_blob_const( + id21->lm_owf_password.array, 16); + uint8_t outbuf[16] = { 0, }; + DATA_BLOB out = data_blob_const( + outbuf, sizeof(outbuf)); if ((id21->lm_owf_password.length != 16) || (id21->lm_owf_password.size != 16)) { @@ -4749,9 +4754,6 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21, return NT_STATUS_NO_USER_SESSION_KEY; } - in = data_blob_const(id21->lm_owf_password.array, 16); - out = data_blob_talloc_zero(mem_ctx, 16); - rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT); if (rc != 0) { return gnutls_error_to_ntstatus(rc,