]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server: Slightly simplify set_user_info_21()
authorVolker Lendecke <vl@samba.org>
Tue, 17 Aug 2021 18:18:45 +0000 (20:18 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 24 Aug 2021 17:32:28 +0000 (17:32 +0000)
Instead of adding the NULL check to data_blob_talloc_zero() put "out"
on the stack.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpc_server/samr/srv_samr_nt.c

index 28000677fc83c8a586e2e2789400ee488dd5a2f6..b4c72d901b37f3eea4993edf6266d91e0de3ce1f 100644 (file)
@@ -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,