s3-rpc_client: Fixed a segfault in rpccli_samr_chng_pswd_auth_crap().
[sfrench/samba-autobuild/.git] / source3 / rpc_client / cli_samr.c
index 5a0dff296595dc80855440002683053bc0e48dd7..8c1011293afb6b67e963c3b90042318fa2466e1f 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "includes.h"
 #include "../libcli/auth/libcli_auth.h"
+#include "../librpc/gen_ndr/cli_samr.h"
+#include "rpc_client/cli_samr.h"
+#include "../lib/crypto/arcfour.h"
 
 /* User change password */
 
@@ -162,10 +165,29 @@ NTSTATUS rpccli_samr_chng_pswd_auth_crap(struct rpc_pipe_client *cli,
        init_lsa_String(&server, cli->srv_name_slash);
        init_lsa_String(&account, username);
 
-       memcpy(&new_nt_password.data, new_nt_password_blob.data, 516);
-       memcpy(&new_lm_password.data, new_lm_password_blob.data, 516);
-       memcpy(&old_nt_hash_enc.hash, old_nt_hash_enc_blob.data, 16);
-       memcpy(&old_lm_hash_enc.hash, old_lm_hash_enc_blob.data, 16);
+       if (new_nt_password_blob.length > 0) {
+               memcpy(&new_nt_password.data, new_nt_password_blob.data, 516);
+       } else {
+               ZERO_STRUCT(new_nt_password_blob);
+       }
+
+       if (new_lm_password_blob.length > 0) {
+               memcpy(&new_lm_password.data, new_lm_password_blob.data, 516);
+       } else {
+               ZERO_STRUCT(new_lm_password);
+       }
+
+       if (old_nt_hash_enc_blob.length > 0) {
+               memcpy(&old_nt_hash_enc.hash, old_nt_hash_enc_blob.data, 16);
+       } else {
+               ZERO_STRUCT(old_nt_hash_enc);
+       }
+
+       if (old_lm_hash_enc_blob.length > 0) {
+               memcpy(&old_lm_hash_enc.hash, old_lm_hash_enc_blob.data, 16);
+       } else {
+               ZERO_STRUCT(old_lm_hash_enc);
+       }
 
        result = rpccli_samr_ChangePasswordUser2(cli, mem_ctx,
                                                 &server,
@@ -187,7 +209,7 @@ NTSTATUS rpccli_samr_chgpasswd_user3(struct rpc_pipe_client *cli,
                                     const char *newpassword,
                                     const char *oldpassword,
                                     struct samr_DomInfo1 **dominfo1,
-                                    struct samr_ChangeReject **reject)
+                                    struct userPwdChangeFailureInformation **reject)
 {
        NTSTATUS status;