r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
[vlendec/samba-autobuild/.git] / source3 / utils / ntlm_auth_diagnostics.c
index 40c627588de07d46ae3b661b84ede49d896e3b0f..e69715affd024300c9a1860176aae6d3000c542f 100644 (file)
@@ -23,7 +23,7 @@
 */
 
 #include "includes.h"
-#include "../utils/ntlm_auth.h"
+#include "utils/ntlm_auth.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -445,6 +445,7 @@ static BOOL test_plaintext(enum ntlm_break break_which)
        DATA_BLOB nt_response = data_blob(NULL, 0);
        DATA_BLOB lm_response = data_blob(NULL, 0);
        char *password;
+       smb_ucs2_t *nt_response_ucs2;
 
        uchar user_session_key[16];
        uchar lm_key[16];
@@ -457,26 +458,30 @@ static BOOL test_plaintext(enum ntlm_break break_which)
        flags |= WBFLAG_PAM_LMKEY;
        flags |= WBFLAG_PAM_USER_SESSION_KEY;
 
-       if ((push_ucs2_allocate((smb_ucs2_t **)&nt_response.data, opt_password)) == -1) {
+       if ((push_ucs2_allocate(&nt_response_ucs2, opt_password)) == -1) {
                DEBUG(0, ("push_ucs2_allocate failed!\n"));
                exit(1);
        }
 
-       nt_response.length = strlen_w(((void *)nt_response.data))*sizeof(smb_ucs2_t);
+       nt_response.data = (unsigned char *)nt_response_ucs2;
+       nt_response.length = strlen_w(nt_response_ucs2)*sizeof(smb_ucs2_t);
 
-       password = strdup_upper(opt_password);
+       if ((password = strdup_upper(opt_password)) == NULL) {
+               DEBUG(0, ("strdup_upper failed!\n"));
+               exit(1);
+       }
 
        if ((convert_string_allocate(NULL, CH_UNIX, 
                                     CH_DOS, password,
                                     strlen(password)+1, 
-                                    (void**)&lm_response.data,True)) == -1) {
-               DEBUG(0, ("push_ascii_allocate failed!\n"));
+                                    &lm_response.data,True)) == -1) {
+               DEBUG(0, ("convert_string_allocate failed!\n"));
                exit(1);
        }
 
        SAFE_FREE(password);
 
-       lm_response.length = strlen(lm_response.data);
+       lm_response.length = strlen((const char *)lm_response.data);
 
        switch (break_which) {
        case BREAK_NONE:
@@ -580,7 +585,8 @@ static const struct ntlm_tests {
        {test_plaintext_lm_broken, "Plaintext LM broken"},
        {test_plaintext_nt_broken, "Plaintext NT broken"},
        {test_plaintext_nt_only, "Plaintext NT only"},
-       {test_plaintext_lm_only, "Plaintext LM only"}
+       {test_plaintext_lm_only, "Plaintext LM only"},
+       {NULL, NULL}
 };
 
 BOOL diagnose_ntlm_auth(void)