Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c315e818b6d492241f7e717fe23a9fe9094e503a
https://github.com/WebKit/WebKit/commit/c315e818b6d492241f7e717fe23a9fe9094e503a
Author: Ahmad Saleem <[email protected]>
Date: 2026-09-14 (Mon, 14 Sep 2026)
Changed paths:
M Source/WebCore/platform/network/cocoa/RangeResponseGenerator.mm
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebCoreNSURLSession.mm
Log Message:
-----------
RangeResponseGenerator drops the last byte of a range when the buffer
momentarily ends exactly on the range's final index
https://bugs.webkit.org/show_bug.cgi?id=323990
rdar://187225949
Reviewed by Alex Christensen.
RangeResponseGenerator delivers a closed byte range [begin, end]. The
byte-delivery loop correctly uses an inclusive guard (byteIndex > end),
but the post-loop completion check used byteIndex >= end. When the range's
last byte (index `end`) has not yet arrived and the received buffer size
is exactly `end`, the loop delivers indices begin..end-1, breaks on
byteIndex >= bufferSize with byteIndex == end, and the completion check
byteIndex >= end then finishes the task and queues its removal. The final
byte, which arrives in a later dataReceived, is never delivered, so the
range is truncated by one byte.
Fix the completion check to use byteIndex > end so the task only finishes
once delivery has passed the range's inclusive end, matching the in-loop
guard.
Added an API test that drives data into the generator in controlled chunks
via a test PlatformMediaResourceLoader, so the buffer lands exactly on the
range end before the last byte arrives. The test fails without the fix
(99 of 100 bytes delivered) and passes with it.
Test: Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebCoreNSURLSession.mm
* Source/WebCore/platform/network/cocoa/RangeResponseGenerator.mm:
(WebCore::RangeResponseGenerator::giveResponseToTaskIfBytesInRangeReceived):
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/WebCoreNSURLSession.mm:
(-[TestRangeSessionDelegate
URLSession:dataTask:didReceiveResponse:completionHandler:]):
(-[TestRangeSessionDelegate URLSession:dataTask:didReceiveData:]):
(-[TestRangeSessionDelegate URLSession:task:didCompleteWithError:]):
(TestWebKitAPI::TEST_F(WebCoreNSURLSessionTest,
RangeResponseDeliversLastByteAtChunkBoundary)):
Canonical link: https://commits.webkit.org/321101@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications