winhttp: Mind read size when skipping async read in WinHttpReadData().

This commit is contained in:
Paul Gofman 2024-02-20 16:03:44 -06:00 committed by Alexandre Julliard
parent a3686eeb5e
commit 9c1bc32fe9

View file

@ -3062,9 +3062,11 @@ static DWORD query_data_ready( struct request *request )
return count;
}
static BOOL skip_async_queue( struct request *request, BOOL *wont_block )
static BOOL skip_async_queue( struct request *request, BOOL *wont_block, DWORD to_read )
{
*wont_block = end_of_read_data( request ) || query_data_ready( request );
if (!request->read_chunked)
to_read = min( to_read, request->content_length - request->content_read );
*wont_block = end_of_read_data( request ) || query_data_ready( request ) >= to_read;
return request->hdr.recursion_count < 3 && *wont_block;
}
@ -3133,7 +3135,7 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
return FALSE;
}
if (!(async = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) || skip_async_queue( request, &wont_block ))
if (!(async = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) || skip_async_queue( request, &wont_block, 1 ))
{
ret = query_data_available( request, available, async );
}
@ -3229,7 +3231,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, void *buffer, DWORD to_read, DW
return FALSE;
}
if (!(async = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) || skip_async_queue( request, &wont_block ))
if (!(async = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) || skip_async_queue( request, &wont_block, to_read ))
{
ret = read_data( request, buffer, to_read, read, async );
}