]> granicus.if.org Git - curl/commitdiff
ntlm: Avoid unnecessary buffer allocation for SSPI based type-2 token
authorSteve Holme <steve_holme@hotmail.com>
Thu, 16 Oct 2014 19:22:20 +0000 (20:22 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Thu, 16 Oct 2014 19:19:33 +0000 (20:19 +0100)
lib/curl_ntlm_msgs.c
lib/urldata.h

index 0b76827e7ddabac873b482da43383d66ec311809..0c983b781f005d0cd3527ba8141f825e9b41e3fb 100644 (file)
@@ -297,13 +297,8 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
   }
 
 #ifdef USE_WINDOWS_SSPI
-  ntlm->type_2 = malloc(size + 1);
-  if(ntlm->type_2 == NULL) {
-    free(buffer);
-    return CURLE_OUT_OF_MEMORY;
-  }
+  ntlm->type_2 = buffer;
   ntlm->n_type_2 = curlx_uztoul(size);
-  memcpy(ntlm->type_2, buffer, size);
 #else
   ntlm->flags = 0;
 
@@ -336,8 +331,9 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
     fprintf(stderr, "\n****\n");
     fprintf(stderr, "**** Header %s\n ", header);
   });
-#endif
+
   free(buffer);
+#endif
 
   return CURLE_OK;
 }
index e9ddf30b81cdff90496e94eeceb28a2b645c823e..900b8c8ad0eee58bc20d58686d653d9e94512ef9 100644 (file)
@@ -442,7 +442,7 @@ struct ntlmdata {
   size_t max_token_length;
   BYTE *output_token;
   int has_handles;
-  void *type_2;
+  BYTE *type_2;
   unsigned long n_type_2;
 #else
   unsigned int flags;