diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-05-21 14:18:40 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-06-24 15:00:41 +0100 |
commit | 8048ba7045bae3ee305c4869698cfc4036a329fd (patch) | |
tree | 8737fccf4c2cc26b1b13d395238ce97baa8f6f38 /src | |
parent | db6b8f7db1973ad874a8ec1d147ad8e98e65d9cb (diff) | |
download | libgit2-8048ba7045bae3ee305c4869698cfc4036a329fd.tar.gz |
winhttp: safely cast length to DWORD
Diffstat (limited to 'src')
-rw-r--r-- | src/transports/winhttp.c | 7 |
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) |