]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Curl_ntlm_core_mk_nt_hash: fix OOM in error path
authorHarry Sintonen <sintonen@iki.fi>
Tue, 1 Jun 2021 09:31:15 +0000 (11:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 1 Jun 2021 11:38:01 +0000 (13:38 +0200)
Closes #7164

lib/curl_ntlm_core.c

index 89d4ec872eb7d8a95a37b7c2a50a821e56bf45b7..ef9b7480b83efa60817148e8fbf52ccb33a600ce 100644 (file)
@@ -498,17 +498,14 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
    * network encoding not the host encoding.
    */
   result = Curl_convert_to_network(data, (char *)pw, len * 2);
-  if(result)
-    return result;
-
-  /* Create NT hashed password. */
-  Curl_md4it(ntbuffer, pw, 2 * len);
-
-  memset(ntbuffer + 16, 0, 21 - 16);
-
+  if(!result) {
+    /* Create NT hashed password. */
+    Curl_md4it(ntbuffer, pw, 2 * len);
+    memset(ntbuffer + 16, 0, 21 - 16);
+  }
   free(pw);
 
-  return CURLE_OK;
+  return result;
 }
 
 #if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI)