libcli:auth: Return NTSTATUS for encode_or_decode_arc4_passwd_buffer()
authorAndreas Schneider <asn@samba.org>
Wed, 29 May 2019 12:57:52 +0000 (14:57 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 26 Jul 2019 01:48:22 +0000 (01:48 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/auth/proto.h
libcli/auth/smbencrypt.c
source3/rpc_server/samr/srv_samr_nt.c

index afd7f0d148d99c042edc2874a07c686dc779882f..651f1139cf505ad2ea37a8f15ea2b2343a77dcaa 100644 (file)
@@ -184,7 +184,8 @@ bool decode_pw_buffer(TALLOC_CTX *ctx,
 /***********************************************************
  Decode an arc4 encrypted password change buffer.
 ************************************************************/
-void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key);
+NTSTATUS encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532],
+                                            const DATA_BLOB *psession_key);
 
 /***********************************************************
  encode a password buffer with an already unicode password.  The
index a74ccf09b023662d5fd40ea325fd5cdd25643d55..ae97f3cc93e10327be8ae742e1b3dece310a47c8 100644 (file)
@@ -843,27 +843,32 @@ bool decode_pw_buffer(TALLOC_CTX *ctx,
  Decode an arc4 encrypted password change buffer.
 ************************************************************/
 
-void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key)
+NTSTATUS encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532],
+                                            const DATA_BLOB *psession_key)
 {
        gnutls_hash_hd_t hash_hnd = NULL;
        unsigned char key_out[16];
+       NTSTATUS status;
        int rc;
 
        /* Confounder is last 16 bytes. */
 
        rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
        if (rc < 0) {
+               status = gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
                goto out;
        }
 
        rc = gnutls_hash(hash_hnd, &pw_buf[516], 16);
        if (rc < 0) {
                gnutls_hash_deinit(hash_hnd, NULL);
+               status = gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
                goto out;
        }
        rc = gnutls_hash(hash_hnd, psession_key->data, psession_key->length);
        if (rc < 0) {
                gnutls_hash_deinit(hash_hnd, NULL);
+               status = gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
                goto out;
        }
        gnutls_hash_deinit(hash_hnd, key_out);
@@ -873,8 +878,9 @@ void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_B
 
        ZERO_ARRAY(key_out);
 
+       status = NT_STATUS_OK;
 out:
-       return;
+       return status;
 }
 
 /***********************************************************
index 124d6d38cd707ea46716e1eb18a9165fd52150b5..c2be8bfc19adff0e9505372304e263c3d785fdcd 100644 (file)
@@ -5185,9 +5185,12 @@ NTSTATUS _samr_SetUserInfo(struct pipes_struct *p,
                        if(!NT_STATUS_IS_OK(status)) {
                                break;
                        }
-                       encode_or_decode_arc4_passwd_buffer(
+                       status = encode_or_decode_arc4_passwd_buffer(
                                info->info25.password.data,
                                &session_key);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               break;
+                       }
 
                        dump_data(100, info->info25.password.data, 532);
 
@@ -5201,9 +5204,12 @@ NTSTATUS _samr_SetUserInfo(struct pipes_struct *p,
                        if(!NT_STATUS_IS_OK(status)) {
                                break;
                        }
-                       encode_or_decode_arc4_passwd_buffer(
+                       status = encode_or_decode_arc4_passwd_buffer(
                                info->info26.password.data,
                                &session_key);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               break;
+                       }
 
                        dump_data(100, info->info26.password.data, 516);