aboutsummaryrefslogtreecommitdiff
path: root/lib/http_ntlm.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2011-08-25 15:09:30 +0200
committerYang Tse <yangsita@gmail.com>2011-08-25 15:13:13 +0200
commitd535cff77517214015e2d495677c40cfdec93053 (patch)
tree7143a27a6f4c985e6db2331458e67793c5224156 /lib/http_ntlm.c
parentf5ad192d2373b24ef600358adb78bf02beffe426 (diff)
http NTLM: refactoring followup
Output of Curl_ntlm_create_type1_message() and Curl_ntlm_create_type3_message() functions is now already base64 encoded.
Diffstat (limited to 'lib/http_ntlm.c')
-rw-r--r--lib/http_ntlm.c65
1 files changed, 20 insertions, 45 deletions
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c
index c5ee679a9..6e07fe977 100644
--- a/lib/http_ntlm.c
+++ b/lib/http_ntlm.c
@@ -453,13 +453,10 @@ CURLcode Curl_output_ntlm_sso(struct connectdata *conn,
CURLcode Curl_output_ntlm(struct connectdata *conn,
bool proxy)
{
- size_t size = 0;
char *base64 = NULL;
- size_t base64_sz = 0;
- unsigned char ntlmbuf[NTLM_BUFSIZE];
CURLcode error;
- /* point to the address of the pointer that holds the string to sent to the
+ /* point to the address of the pointer that holds the string to send to the
server, which is for a plain host or for a HTTP proxy */
char **allocuserpwd;
@@ -514,61 +511,39 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
switch(ntlm->state) {
case NTLMSTATE_TYPE1:
default: /* for the weird cases we (re)start here */
-
/* Create a type-1 message */
-
- error = Curl_ntlm_create_type1_message(userp, passwdp,
- ntlm, ntlmbuf, &size);
+ error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64);
if(error)
return error;
- if(size > 0) {
- /* convert the binary blob into base64 */
- error = Curl_base64_encode(NULL, (char *)ntlmbuf, size,
- &base64, &base64_sz);
- if(error)
- return error;
-
- if(base64_sz > 0) {
- Curl_safefree(*allocuserpwd);
- *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
- proxy ? "Proxy-" : "",
- base64);
- DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd));
- free(base64);
- }
+ if(base64) {
+ Curl_safefree(*allocuserpwd);
+ *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
+ proxy ? "Proxy-" : "",
+ base64);
+ DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd));
+ free(base64);
}
-
break;
case NTLMSTATE_TYPE2:
/* We already received the type-2 message, create a type-3 message */
-
error = Curl_ntlm_create_type3_message(conn->data, userp, passwdp,
- ntlm, ntlmbuf, &size);
+ ntlm, &base64);
if(error)
return error;
- if(size > 0) {
- /* convert the binary blob into base64 */
- error = Curl_base64_encode(NULL, (char *)ntlmbuf, size,
- &base64, &base64_sz);
- if(error)
- return error;
-
- if(base64_sz > 0) {
- Curl_safefree(*allocuserpwd);
- *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
- proxy ? "Proxy-" : "",
- base64);
- DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd));
- free(base64);
-
- ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */
- authp->done = TRUE;
- }
- }
+ if(base64) {
+ Curl_safefree(*allocuserpwd);
+ *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
+ proxy ? "Proxy-" : "",
+ base64);
+ DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd));
+ free(base64);
+ ntlm->state = NTLMSTATE_TYPE3; /* we send a type-3 */
+ authp->done = TRUE;
+ }
break;
case NTLMSTATE_TYPE3: