summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-05-21 14:18:40 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-24 15:00:41 +0100
commit8048ba7045bae3ee305c4869698cfc4036a329fd (patch)
tree8737fccf4c2cc26b1b13d395238ce97baa8f6f38
parentdb6b8f7db1973ad874a8ec1d147ad8e98e65d9cb (diff)
downloadlibgit2-8048ba7045bae3ee305c4869698cfc4036a329fd.tar.gz
winhttp: safely cast length to DWORD
-rw-r--r--src/transports/winhttp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index 6392a7d1c..2829ada96 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -816,6 +816,11 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
int attempts;
bool success;
+ if (len > DWORD_MAX) {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return -1;
+ }
+
for (attempts = 0; attempts < 5; attempts++) {
if (ignore_length) {
success = WinHttpSendRequest(s->request,
@@ -826,7 +831,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
success = WinHttpSendRequest(s->request,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
- len, 0);
+ (DWORD)len, 0);
}
if (success || GetLastError() != (DWORD)SEC_E_BUFFER_TOO_SMALL)