diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-07-06 05:09:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:09:47 -0500 |
commit | 3aa8a700e6b838ffc32bb7e9aebbb197e91c4704 (patch) | |
tree | 1c60a31d5bad26eb7eb390f162a0f772d2c47d7b /source4/torture | |
parent | 44e6f21393ea6f2531c6d1e789a0a01582bc6dca (diff) | |
download | samba-3aa8a700e6b838ffc32bb7e9aebbb197e91c4704.tar.gz samba-3aa8a700e6b838ffc32bb7e9aebbb197e91c4704.tar.bz2 samba-3aa8a700e6b838ffc32bb7e9aebbb197e91c4704.zip |
r16826: Ensure we don't segfault if the remote server fails to set a password
in RPC-SAMR test.
Andrew Bartlett
(This used to be commit 08ec74d620ffe613655f28d002e60ca8201fadd9)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/rpc/samr.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 5049381b21..bdff980950 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -942,7 +942,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6; struct policy_handle user_handle; - char *oldpass = *password; + char *oldpass; uint8_t old_nt_hash[16], new_nt_hash[16]; uint8_t old_lm_hash[16], new_lm_hash[16]; @@ -964,6 +964,13 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("Testing ChangePasswordUser\n"); + if (!*password) { + printf("Failing ChangePasswordUser as old password was NULL. Previous test failed?\n"); + return False; + } + + oldpass = *password; + E_md4hash(oldpass, old_nt_hash); E_md4hash(newpass, new_nt_hash); E_deshash(oldpass, old_lm_hash); @@ -1015,7 +1022,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c struct samr_Password lm_verifier; struct samr_CryptPassword lm_pass; struct lsa_AsciiString server, account, account_bad; - char *oldpass = *password; + char *oldpass; char *newpass; uint8_t old_lm_hash[16], new_lm_hash[16]; @@ -1023,11 +1030,19 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c int policy_min_pw_len = 0; struct lsa_String domain_name; + domain_name.string = ""; dom_pw_info.in.domain_name = &domain_name; printf("Testing OemChangePasswordUser2\n"); + if (!*password) { + printf("Failing OemChangePasswordUser2 as old password was NULL. Previous test failed?\n"); + return False; + } + + oldpass = *password; + status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &dom_pw_info); if (NT_STATUS_IS_OK(status)) { policy_min_pw_len = dom_pw_info.out.info.min_password_length; @@ -1109,7 +1124,7 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_String server, account; struct samr_CryptPassword nt_pass, lm_pass; struct samr_Password nt_verifier, lm_verifier; - char *oldpass = *password; + char *oldpass; char *newpass; uint8_t old_nt_hash[16], new_nt_hash[16]; uint8_t old_lm_hash[16], new_lm_hash[16]; @@ -1118,11 +1133,19 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, int policy_min_pw_len = 0; struct lsa_String domain_name; + + domain_name.string = ""; dom_pw_info.in.domain_name = &domain_name; printf("Testing ChangePasswordUser2\n"); + if (!*password) { + printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n"); + return False; + } + oldpass = *password; + status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &dom_pw_info); if (NT_STATUS_IS_OK(status)) { policy_min_pw_len = dom_pw_info.out.info.min_password_length; @@ -1180,13 +1203,19 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_String server, account, account_bad; struct samr_CryptPassword nt_pass, lm_pass; struct samr_Password nt_verifier, lm_verifier; - char *oldpass = *password; + char *oldpass; char *newpass = samr_rand_pass(mem_ctx, policy_min_pw_len); uint8_t old_nt_hash[16], new_nt_hash[16]; uint8_t old_lm_hash[16], new_lm_hash[16]; printf("Testing ChangePasswordUser3\n"); + if (!*password) { + printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n"); + return False; + } + + oldpass = *password; server.string = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); init_lsa_String(&account, account_string); @@ -1776,7 +1805,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!test_SetUserPass(p, user_ctx, user_handle, &password)) { ret = False; - } + } for (i = 0; password_fields[i]; i++) { if (!test_SetUserPass_23(p, user_ctx, user_handle, password_fields[i], &password)) { |