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

Bugfix in the baze-core/util/IdentityWriter causing upload failure #2922

Closed

Conversation

@mi-char
Copy link

@mi-char mi-char commented Oct 23, 2019

Bug causes failure of a chunked upload in case when Content-Length (Long) converted to Int32 overflows to a positive number.

Test case: chunked upload of file with a content length 4,294,967,300 bytes.
Result: IllegalArgumentException("Will not write more bytes than what was indicated by the Content-Length header 4")

…f chunked upload of data when Content-Length % Int32.Max > Int32.Max
@@ -38,7 +38,7 @@ private[http4s] class IdentityWriter[F[_]](size: Int, out: TailStage[ByteBuffer]

logger.warn(msg)

val reducedChunk = chunk.take(size - bodyBytesWritten)
val reducedChunk = chunk.take((size - bodyBytesWritten).toInt)
Copy link
Author

@mi-char mi-char Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion to Int on this place is safe as long as chunk.size is also Int.

…f chunked upload of data when Content-Length (Long) converted to Int32 overflows to a positive number.
@mi-char
Copy link
Author

@mi-char mi-char commented Oct 30, 2019

Please review this PR @rossabaker | @bryce-anderson | @ChristopherDavenport | @aeons

This bug is causing us errors in production.

Copy link
Member

@rossabaker rossabaker left a comment

This looks good to me. We could release it on 0.20.x if it's on the series/0.20 branch.

@mi-char
Copy link
Author

@mi-char mi-char commented Oct 30, 2019

Thank you.
Should I change this PR to the series/0.20 branch, or leave this one to the master and create new PR to the 0.20?

@rossabaker
Copy link
Member

@rossabaker rossabaker commented Oct 30, 2019

I can cherry pick it back tonight and get a release.going.

@mi-char
Copy link
Author

@mi-char mi-char commented Oct 30, 2019

That would be perfect. So I will leave on the master branch.
Thank you in advance for the release.
And big thanks for the https4s.

@rossabaker rossabaker mentioned this pull request Oct 31, 2019
@rossabaker
Copy link
Member

@rossabaker rossabaker commented Oct 31, 2019

This is cherry-picked and released as 0.20.12.

@rossabaker rossabaker closed this Oct 31, 2019
@mi-char mi-char deleted the bugfix/identity_writer-max_size_check branch Oct 31, 2019
aeons added a commit that referenced this issue Nov 5, 2019
Backport #2922: chunked upload of long Content-Lengths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants