r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the
[nivanova/samba-autobuild/.git] / source4 / libcli / auth / ntlmssp.c
index 55a80d0d5eb3506a6a777402d69f730ebba2c97f..d5ddcfbfb62f48068441d3e0b1cbc0091f499d20 100644 (file)
@@ -109,7 +109,7 @@ void debug_ntlmssp_flags(uint32_t neg_flags)
    
 static const uint8_t *get_challenge(const struct ntlmssp_state *ntlmssp_state)
 {
-       uint8_t *chal = talloc(ntlmssp_state, 8);
+       uint8_t *chal = talloc_size(ntlmssp_state, 8);
        generate_random_buffer(chal, 8);
 
        return chal;
@@ -145,6 +145,10 @@ static NTSTATUS set_challenge(struct ntlmssp_state *ntlmssp_state, DATA_BLOB *ch
 
 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) 
 {
+       if (!user) {
+               /* it should be at least "" */
+               return NT_STATUS_INVALID_PARAMETER;
+       }
        ntlmssp_state->user = talloc_strdup(ntlmssp_state, user);
        if (!ntlmssp_state->user) {
                return NT_STATUS_NO_MEMORY;
@@ -264,7 +268,7 @@ NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
                                 "NTLMSSP",
                                 &ntlmssp_command)) {
                        DEBUG(1, ("Failed to parse NTLMSSP packet, could not extract NTLMSSP command\n"));
-                       dump_data(2, (const char *)input.data, input.length);
+                       dump_data(2, input.data, input.length);
                        return NT_STATUS_INVALID_PARAMETER;
                }
        }
@@ -472,7 +476,7 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state,
                                 &cliname,
                                 &domname)) {
                        DEBUG(1, ("ntlmssp_server_negotiate: failed to parse NTLMSSP:\n"));
-                       dump_data(2, (const char *)in.data, in.length);
+                       dump_data(2, in.data, in.length);
                        return NT_STATUS_INVALID_PARAMETER;
                }
                
@@ -611,7 +615,7 @@ static NTSTATUS ntlmssp_server_preauth(struct ntlmssp_state *ntlmssp_state,
                         &ntlmssp_state->encrypted_session_key,
                         &auth_flags)) {
                DEBUG(10, ("ntlmssp_server_auth: failed to parse NTLMSSP (nonfatal):\n"));
-               dump_data(10, (const char *)request.data, request.length);
+               dump_data(10, request.data, request.length);
 
                /* zero this out */
                data_blob_free(&ntlmssp_state->encrypted_session_key);
@@ -635,7 +639,7 @@ static NTSTATUS ntlmssp_server_preauth(struct ntlmssp_state *ntlmssp_state,
                                 &user, 
                                 &workstation)) {
                        DEBUG(1, ("ntlmssp_server_auth: failed to parse NTLMSSP:\n"));
-                       dump_data(2, (const char *)request.data, request.length);
+                       dump_data(2, request.data, request.length);
 
                        return NT_STATUS_INVALID_PARAMETER;
                }
@@ -905,7 +909,7 @@ static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state,
 
 NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx, struct ntlmssp_state **ntlmssp_state)
 {
-       *ntlmssp_state = talloc_p(mem_ctx, struct ntlmssp_state);
+       *ntlmssp_state = talloc(mem_ctx, struct ntlmssp_state);
        if (!*ntlmssp_state) {
                DEBUG(0,("ntlmssp_server_start: talloc failed!\n"));
                return NT_STATUS_NO_MEMORY;
@@ -1027,7 +1031,7 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
                         &server_domain_blob,
                         &chal_flags)) {
                DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#1)\n"));
-               dump_data(2, (const char *)in.data, in.length);
+               dump_data(2, in.data, in.length);
 
                return NT_STATUS_INVALID_PARAMETER;
        }
@@ -1069,7 +1073,7 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
                         &unkn1, &unkn2,
                         &struct_blob)) {
                DEBUG(1, ("Failed to parse the NTLMSSP Challenge: (#2)\n"));
-               dump_data(2, (const char *)in.data, in.length);
+               dump_data(2, in.data, in.length);
                return NT_STATUS_INVALID_PARAMETER;
        }
 
@@ -1104,7 +1108,8 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
                                      ntlmssp_state->domain, 
                                      ntlmssp_state->password, &challenge_blob, 
                                      &struct_blob, 
-                                     &lm_response, &nt_response, &session_key)) {
+                                     &lm_response, &nt_response, 
+                                     NULL, &session_key)) {
                        data_blob_free(&challenge_blob);
                        data_blob_free(&struct_blob);
                        return NT_STATUS_NO_MEMORY;
@@ -1135,7 +1140,7 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
 
                DEBUG(5, ("NTLMSSP challenge set by NTLM2\n"));
                DEBUG(5, ("challenge is: \n"));
-               dump_data(5, (const char *)session_nonce_hash, 8);
+               dump_data(5, session_nonce_hash, 8);
                
                nt_response = data_blob_talloc(ntlmssp_state, NULL, 24);
                SMBNTencrypt(ntlmssp_state->password,
@@ -1252,18 +1257,19 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
 
        ntlmssp_state->expected_state = NTLMSSP_DONE;
 
-       if (!NT_STATUS_IS_OK(nt_status = ntlmssp_sign_init(ntlmssp_state))) {
+       nt_status = ntlmssp_sign_init(ntlmssp_state);
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(1, ("Could not setup NTLMSSP signing/sealing system (error was: %s)\n", 
                          nt_errstr(nt_status)));
                return nt_status;
        }
 
-       return NT_STATUS_MORE_PROCESSING_REQUIRED;
+       return nt_status;
 }
 
 NTSTATUS ntlmssp_client_start(TALLOC_CTX *mem_ctx, struct ntlmssp_state **ntlmssp_state)
 {
-       *ntlmssp_state = talloc_p(mem_ctx, struct ntlmssp_state);
+       *ntlmssp_state = talloc(mem_ctx, struct ntlmssp_state);
        if (!*ntlmssp_state) {
                DEBUG(0,("ntlmssp_client_start: talloc failed!\n"));
                return NT_STATUS_NO_MEMORY;