Skip to content

Honor exclusive ranges in EncryptedDiskService#download_chunk - #15

Open
khalilgharbaoui wants to merge 1 commit into
cheddar-me:mainfrom
khalilgharbaoui:honor-exclusive-ranges-in-download-chunk
Open

khalilgharbaoui wants to merge 1 commit into
cheddar-me:mainfrom
khalilgharbaoui:honor-exclusive-ranges-in-download-chunk

Conversation

@khalilgharbaoui

Copy link
Copy Markdown

download_chunk passes the range to the scheme unchanged, and the schemes count an inclusive range (range.end - range.begin + 1), so an exclusive range returns one byte too many.

That is not hypothetical: ActiveStorage reads 0...4.kilobytes when it identifies a blob, so today that call returns 4097 bytes. The stock S3Service and GCSService both honour exclude_end?, so the encrypted disk service is the odd one out.

One line, plus a regression test asserting the exclusive read matches the same slice of the plaintext. 73 runs, 0 failures.

The range was passed to the scheme unchanged, and the schemes count an
inclusive range, so an exclusive one returned one byte too many. ActiveStorage
passes 0...4.kilobytes when it identifies a blob, and both the stock S3Service
and GCSService honour exclude_end?.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant