curl_ntlm_core: Fixed use of long long for VC6 and VC7
authorSteve Holme <steve_holme@hotmail.com>
Sun, 4 May 2014 17:59:55 +0000 (18:59 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Sun, 4 May 2014 18:07:17 +0000 (19:07 +0100)
Commit 07b66cbfa4 unfortunately broke native NTLM message support in
compilers, such as VC6, VC7 and others, that don't support long long
type declarations. This commit fixes VC6 and VC7 as they support the
__int64 extension, however, we should consider an additional fix for
other compilers that don't support this.

lib/curl_ntlm_core.c

index 4420981..4f30cc6 100644 (file)
@@ -402,7 +402,11 @@ static void write32_le(const int value, unsigned char *buffer)
   buffer[3] = (char)((value & 0xFF000000) >> 24);
 }
 
+#if defined(HAVE_LONGLONG)
 static void write64_le(const long long value, unsigned char *buffer)
+#else
+static void write64_le(const __int64 value, unsigned char *buffer)
+#endif
 {
   write32_le((int)value, buffer);
   write32_le((int)(value >> 32), buffer + 4);
@@ -550,16 +554,27 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
   unsigned int len = 0;
   unsigned char *ptr = NULL;
   unsigned char hmac_output[NTLM_HMAC_MD5_LEN];
+#if defined(HAVE_LONGLONG)
   long long tw;
+#else
+  __int64 tw;
+#endif
   CURLcode res = CURLE_OK;
 
   /* Calculate the timestamp */
+#if defined(HAVE_LONGLONG)
 #if defined(DEBUGBUILD)
   tw = 11644473600ULL * 10000000ULL;
 #else
   tw = ((long long)time(NULL) + 11644473600ULL) * 10000000ULL;
 #endif
-
+#else
+#if defined(DEBUGBUILD)
+  tw = 11644473600ui64 * 10000000ui64;
+#else
+  tw = ((__int64)time(NULL) + 11644473600ui64) * 10000000ui64;
+#endif
+#endif
   /* Calculate the response len */
   len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;