| Index: net/http/http_auth_handler_ntlm.cc
|
| diff --git a/net/http/http_auth_handler_ntlm.cc b/net/http/http_auth_handler_ntlm.cc
|
| index cecf3b2917d7848d76c770a8fce25ee545c60903..36b2ac01ce85b0c9d468727e215a3e2c19be1cbc 100644
|
| --- a/net/http/http_auth_handler_ntlm.cc
|
| +++ b/net/http/http_auth_handler_ntlm.cc
|
| @@ -49,13 +49,6 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl(
|
| LOG(ERROR) << "Username and password are expected to be non-NULL.";
|
| return ERR_MISSING_AUTH_CREDENTIALS;
|
| }
|
| - // TODO(wtc): See if we can use char* instead of void* for in_buf and
|
| - // out_buf. This change will need to propagate to GetNextToken,
|
| - // GenerateType1Msg, and GenerateType3Msg, and perhaps further.
|
| - const void* in_buf;
|
| - void* out_buf;
|
| - uint32_t in_buf_len, out_buf_len;
|
| - std::string decoded_auth_data;
|
|
|
| // The username may be in the form "DOMAIN\user". Parse it into the two
|
| // components.
|
| @@ -73,32 +66,33 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl(
|
| domain_ = domain;
|
| credentials_.Set(user, credentials->password());
|
|
|
| - // Initial challenge.
|
| + std::string decoded_auth_data;
|
| if (auth_data_.empty()) {
|
| - in_buf_len = 0;
|
| - in_buf = NULL;
|
| + // There is no |auth_data_| because the client sends the first message.
|
| int rv = InitializeBeforeFirstChallenge();
|
| if (rv != OK)
|
| return rv;
|
| } else {
|
| + // When |auth_data_| is present it contains the Challenge message.
|
| if (!base::Base64Decode(auth_data_, &decoded_auth_data)) {
|
| LOG(ERROR) << "Unexpected problem Base64 decoding.";
|
| return ERR_UNEXPECTED;
|
| }
|
| - in_buf_len = decoded_auth_data.length();
|
| - in_buf = decoded_auth_data.data();
|
| }
|
|
|
| - int rv = GetNextToken(in_buf, in_buf_len, &out_buf, &out_buf_len);
|
| - if (rv != OK)
|
| - return rv;
|
| + ntlm::Buffer next_token = GetNextToken(
|
| + ntlm::Buffer(reinterpret_cast<const uint8_t*>(decoded_auth_data.data()),
|
| + decoded_auth_data.size()));
|
| + if (next_token.empty())
|
| + return ERR_UNEXPECTED;
|
|
|
| // Base64 encode data in output buffer and prepend "NTLM ".
|
| - std::string encode_input(static_cast<char*>(out_buf), out_buf_len);
|
| std::string encode_output;
|
| - base::Base64Encode(encode_input, &encode_output);
|
| - // OK, we are done with |out_buf|
|
| - free(out_buf);
|
| + base::Base64Encode(
|
| + base::StringPiece(reinterpret_cast<const char*>(next_token.data()),
|
| + next_token.size()),
|
| + &encode_output);
|
| +
|
| *auth_token = std::string("NTLM ") + encode_output;
|
| return OK;
|
| #endif
|
|
|