Skip to content

Commit 8048ba7

Browse files
committed
winhttp: safely cast length to DWORD
1 parent db6b8f7 commit 8048ba7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/transports/winhttp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,11 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
816816
int attempts;
817817
bool success;
818818

819+
if (len > DWORD_MAX) {
820+
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
821+
return -1;
822+
}
823+
819824
for (attempts = 0; attempts < 5; attempts++) {
820825
if (ignore_length) {
821826
success = WinHttpSendRequest(s->request,
@@ -826,7 +831,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
826831
success = WinHttpSendRequest(s->request,
827832
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
828833
WINHTTP_NO_REQUEST_DATA, 0,
829-
len, 0);
834+
(DWORD)len, 0);
830835
}
831836

832837
if (success || GetLastError() != (DWORD)SEC_E_BUFFER_TOO_SMALL)

0 commit comments

Comments
 (0)