Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-by-one error in get_blob with Range #766

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

afontenot
Copy link
Contributor

When range.end == decompressed.len(), the last value in the range will also be the last value in decompressed, because ranges ends are exclusive.

This issue had two consequences that I have noticed. The first is that requesting the last (or only) message part via JMAP will result in the entire message being returned instead, because the range ends on the last byte of the message.

The second issue, which resulted from the first, was that attempting to fetch the last (or only) message part would almost always fail when requested via JMAP if the message part used the quoted-printable transfer encoding. This is because Stalwart would attempt to decode the blob, but since the entire file was returned, this would include headers which are very likely to break assumptions made by the decoder, e.g. unexpected '=' tokens as in 'charset=UTF-8'

The second issue was originally reported here:
#758

When range.end == decompressed.len(), the last value in the range will
also be the last value in decompressed, because ranges ends are
exclusive.

This issue had two consequences that I have noticed. The first is that
requesting the last (or only) message part via JMAP will result in the
entire message being returned instead, because the range ends on the
last byte of the message.

The second issue, which resulted from the first, was that attempting to
fetch the last (or only) message part would almost always fail when
requested via JMAP if the message part used the quoted-printable
transfer encoding. This is because Stalwart would attempt to decode the
blob, but since the entire file was returned, this would include
headers which are very likely to break assumptions made by the decoder,
e.g. unexpected '=' tokens as in 'charset=UTF-8'

The second issue was originally reported here:
stalwartlabs#758
@CLAassistant
Copy link

CLAassistant commented Sep 17, 2024

CLA assistant check
All committers have signed the CLA.

@mdecimus mdecimus merged commit b4c00eb into stalwartlabs:main Sep 22, 2024
4 of 5 checks passed
@afontenot afontenot deleted the fix-obo-get-blob branch September 23, 2024 12:42
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.

3 participants