This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
*
*/
-static BOOL may_set_challenge(const struct ntlmssp_state *ntlmssp_state)
+static bool may_set_challenge(const struct ntlmssp_state *ntlmssp_state)
{
return True;
}
}
static void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
- uint32 neg_flags, BOOL allow_lm) {
+ uint32 neg_flags, bool allow_lm) {
if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) {
ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_UNICODE;
ntlmssp_state->neg_flags &= ~NTLMSSP_NEGOTIATE_OEM;
/**
* Next state function for the Negotiate packet
- *
+ *
* @param ntlmssp_state NTLMSSP State
* @param request The request, as a DATA_BLOB
* @param request The reply, as an allocated DATA_BLOB, caller to free.
- * @return Errors or MORE_PROCESSING_REQUIRED if a reply is sent.
+ * @return Errors or MORE_PROCESSING_REQUIRED if a reply is sent.
*/
static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state,
const DATA_BLOB request, DATA_BLOB *reply)
{
DATA_BLOB struct_blob;
- fstring dnsname, dnsdomname;
+ const char *dnsname;
+ char *dnsdomname = NULL;
uint32 neg_flags = 0;
uint32 ntlmssp_command, chal_flags;
const uint8 *cryptkey;
}
debug_ntlmssp_flags(neg_flags);
}
-
+
ntlmssp_handle_neg_flags(ntlmssp_state, neg_flags, lp_lanman_auth());
/* Ask our caller what challenge they would like in the packet */
/* The flags we send back are not just the negotiated flags,
* they are also 'what is in this packet'. Therfore, we
- * operate on 'chal_flags' from here on
+ * operate on 'chal_flags' from here on
*/
chal_flags = ntlmssp_state->neg_flags;
/* get the right name to fill in as 'target' */
- target_name = ntlmssp_target_name(ntlmssp_state,
- neg_flags, &chal_flags);
- if (target_name == NULL)
+ target_name = ntlmssp_target_name(ntlmssp_state,
+ neg_flags, &chal_flags);
+ if (target_name == NULL)
return NT_STATUS_INVALID_PARAMETER;
ntlmssp_state->chal = data_blob_talloc(ntlmssp_state->mem_ctx, cryptkey, 8);
ntlmssp_state->internal_chal = data_blob_talloc(ntlmssp_state->mem_ctx, cryptkey, 8);
-
/* This should be a 'netbios domain -> DNS domain' mapping */
- dnsdomname[0] = '\0';
- get_mydnsdomname(dnsdomname);
+ dnsdomname = get_mydnsdomname(ntlmssp_state->mem_ctx);
+ if (!dnsdomname) {
+ dnsdomname = talloc_strdup(ntlmssp_state->mem_ctx, "");
+ }
+ if (!dnsdomname) {
+ return NT_STATUS_NO_MEMORY;
+ }
strlower_m(dnsdomname);
-
- dnsname[0] = '\0';
- get_mydnsfullname(dnsname);
-
+
+ dnsname = get_mydnsfullname();
+ if (!dnsname) {
+ dnsname = "";
+ }
+
/* This creates the 'blob' of names that appears at the end of the packet */
- if (chal_flags & NTLMSSP_CHAL_TARGET_INFO)
+ if (chal_flags & NTLMSSP_CHAL_TARGET_INFO)
{
msrpc_gen(&struct_blob, "aaaaa",
NTLMSSP_NAME_TYPE_DOMAIN, target_name,
} else {
gen_string = "CdAdbddB";
}
-
+
msrpc_gen(reply, gen_string,
- "NTLMSSP",
+ "NTLMSSP",
NTLMSSP_CHALLENGE,
target_name,
chal_flags,
0, 0,
struct_blob.data, struct_blob.length);
}
-
+
data_blob_free(&struct_blob);
ntlmssp_state->expected_state = NTLMSSP_AUTH;
/**
* Next state function for the Authenticate packet
- *
+ *
* @param ntlmssp_state NTLMSSP State
* @param request The request, as a DATA_BLOB
* @param request The reply, as an allocated DATA_BLOB, caller to free.
NTSTATUS nt_status = NT_STATUS_OK;
/* used by NTLM2 */
- BOOL doing_ntlm2 = False;
+ bool doing_ntlm2 = False;
uchar session_nonce[16];
uchar session_nonce_hash[16];
session_key.data);
DEBUG(10,("ntlmssp_server_auth: Created NTLM session key.\n"));
} else {
- static const uint8 zeros[24] = { 0, };
+ uint8 zeros[24];
+ ZERO_STRUCT(zeros);
session_key = data_blob_talloc(
ntlmssp_state->mem_ctx, NULL, 16);
if (session_key.data == NULL) {
}
if (!ntlmssp_state->nt_hash || !ntlmssp_state->lm_hash) {
- static const uchar zeros[16] = { 0, };
+ uchar zeros[16];
/* do nothing - blobs are zero length */
+ ZERO_STRUCT(zeros);
+
/* session key is all zeros */
session_key = data_blob_talloc(ntlmssp_state->mem_ctx, zeros, 16);