Loading lib/http_ntlm.c +34 −10 Original line number Original line Diff line number Diff line Loading @@ -658,6 +658,18 @@ ntlm_sspi_cleanup(struct ntlmdata *ntlm) #define HOSTNAME_MAX 1024 #define HOSTNAME_MAX 1024 /* copy the source to the destination and fill in zeroes in every other destination byte! */ static void unicodecpy(unsigned char *dest, const char *src, size_t length) { size_t i; for(i=0; i<length; i++) { dest[2*i] = (unsigned char)src[i]; dest[2*i+1] = '\0'; } } /* this is for creating ntlm header output */ /* this is for creating ntlm header output */ CURLcode Curl_output_ntlm(struct connectdata *conn, CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) bool proxy) Loading Loading @@ -972,6 +984,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, int ntrespoff; int ntrespoff; unsigned char ntresp[24]; /* fixed-size */ unsigned char ntresp[24]; /* fixed-size */ #endif #endif bool unicode = ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE; size_t useroff; size_t useroff; const char *user; const char *user; size_t userlen; size_t userlen; Loading Loading @@ -1004,6 +1017,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, hostlen = strlen(host); hostlen = strlen(host); } } if(unicode) { domlen = domlen * 2; userlen = userlen * 2; hostlen = hostlen * 2; } #if USE_NTLM2SESSION #if USE_NTLM2SESSION /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { Loading Loading @@ -1093,13 +1112,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, useroff = domoff + domlen; useroff = domoff + domlen; hostoff = useroff + userlen; hostoff = useroff + userlen; /* * In the case the server sets the flag NTLMFLAG_NEGOTIATE_UNICODE, we * need to filter it off because libcurl doesn't UNICODE encode the * strings it packs into the NTLM authenticate packet. */ ntlm->flags &= ~NTLMFLAG_NEGOTIATE_UNICODE; /* Create the big type-3 message binary blob */ /* Create the big type-3 message binary blob */ size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), NTLMSSP_SIGNATURE "%c" NTLMSSP_SIGNATURE "%c" Loading Loading @@ -1227,15 +1239,27 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, } } DEBUGASSERT(size == domoff); DEBUGASSERT(size == domoff); if(unicode) unicodecpy(&ntlmbuf[size], domain, domlen/2); else memcpy(&ntlmbuf[size], domain, domlen); memcpy(&ntlmbuf[size], domain, domlen); size += domlen; size += domlen; DEBUGASSERT(size == useroff); DEBUGASSERT(size == useroff); if(unicode) unicodecpy(&ntlmbuf[size], user, userlen/2); else memcpy(&ntlmbuf[size], user, userlen); memcpy(&ntlmbuf[size], user, userlen); size += userlen; size += userlen; DEBUGASSERT(size == hostoff); DEBUGASSERT(size == hostoff); if(unicode) unicodecpy(&ntlmbuf[size], host, hostlen/2); else memcpy(&ntlmbuf[size], host, hostlen); memcpy(&ntlmbuf[size], host, hostlen); size += hostlen; size += hostlen; /* convert domain, user, and host to ASCII but leave the rest as-is */ /* convert domain, user, and host to ASCII but leave the rest as-is */ Loading Loading
lib/http_ntlm.c +34 −10 Original line number Original line Diff line number Diff line Loading @@ -658,6 +658,18 @@ ntlm_sspi_cleanup(struct ntlmdata *ntlm) #define HOSTNAME_MAX 1024 #define HOSTNAME_MAX 1024 /* copy the source to the destination and fill in zeroes in every other destination byte! */ static void unicodecpy(unsigned char *dest, const char *src, size_t length) { size_t i; for(i=0; i<length; i++) { dest[2*i] = (unsigned char)src[i]; dest[2*i+1] = '\0'; } } /* this is for creating ntlm header output */ /* this is for creating ntlm header output */ CURLcode Curl_output_ntlm(struct connectdata *conn, CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) bool proxy) Loading Loading @@ -972,6 +984,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, int ntrespoff; int ntrespoff; unsigned char ntresp[24]; /* fixed-size */ unsigned char ntresp[24]; /* fixed-size */ #endif #endif bool unicode = ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE; size_t useroff; size_t useroff; const char *user; const char *user; size_t userlen; size_t userlen; Loading Loading @@ -1004,6 +1017,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, hostlen = strlen(host); hostlen = strlen(host); } } if(unicode) { domlen = domlen * 2; userlen = userlen * 2; hostlen = hostlen * 2; } #if USE_NTLM2SESSION #if USE_NTLM2SESSION /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ /* We don't support NTLM2 if we don't have USE_NTRESPONSES */ if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) { Loading Loading @@ -1093,13 +1112,6 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, useroff = domoff + domlen; useroff = domoff + domlen; hostoff = useroff + userlen; hostoff = useroff + userlen; /* * In the case the server sets the flag NTLMFLAG_NEGOTIATE_UNICODE, we * need to filter it off because libcurl doesn't UNICODE encode the * strings it packs into the NTLM authenticate packet. */ ntlm->flags &= ~NTLMFLAG_NEGOTIATE_UNICODE; /* Create the big type-3 message binary blob */ /* Create the big type-3 message binary blob */ size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf), NTLMSSP_SIGNATURE "%c" NTLMSSP_SIGNATURE "%c" Loading Loading @@ -1227,15 +1239,27 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, } } DEBUGASSERT(size == domoff); DEBUGASSERT(size == domoff); if(unicode) unicodecpy(&ntlmbuf[size], domain, domlen/2); else memcpy(&ntlmbuf[size], domain, domlen); memcpy(&ntlmbuf[size], domain, domlen); size += domlen; size += domlen; DEBUGASSERT(size == useroff); DEBUGASSERT(size == useroff); if(unicode) unicodecpy(&ntlmbuf[size], user, userlen/2); else memcpy(&ntlmbuf[size], user, userlen); memcpy(&ntlmbuf[size], user, userlen); size += userlen; size += userlen; DEBUGASSERT(size == hostoff); DEBUGASSERT(size == hostoff); if(unicode) unicodecpy(&ntlmbuf[size], host, hostlen/2); else memcpy(&ntlmbuf[size], host, hostlen); memcpy(&ntlmbuf[size], host, hostlen); size += hostlen; size += hostlen; /* convert domain, user, and host to ASCII but leave the rest as-is */ /* convert domain, user, and host to ASCII but leave the rest as-is */ Loading