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

Avoid buffer overflow in runStreamingBuilder #3

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

FinleyMcIlwaine
Copy link
Collaborator

In runStreamingBuilder, if the Builder results in More, we were discarding the minimum required buffer size for the continuation contained in the More. In some (apparently rare) circumstances, this minimum required size may be less than the actual space we have left in the buffer, resulting in a buffer overflow when we run the writer. We now compare the room left in the buffer with the minimum size indicated by the More and flush before writing instead of overflowing the buffer in such cases.

In `runStreamingBuilder`, if the `Builder` results in `More`, we were discarding
the minimum required buffer size for the continuation contained in the `More`.
In some (apparently rare) circumstances, this minimum required size may be less
than the actual space we have left in the buffer, resulting in a buffer overflow
when we run the writer. We now compare the room left in the buffer with the
minimum size indicated by the `More` and flush before writing instead of
overflowing the buffer in such cases.
@kazu-yamamoto kazu-yamamoto self-requested a review June 17, 2024 23:17
Copy link
Owner

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

Nice catch!
This looks good to me.

@kazu-yamamoto kazu-yamamoto merged commit c8d2121 into kazu-yamamoto:main Jun 17, 2024
@kazu-yamamoto
Copy link
Owner

A new version has been released.
Thank you for your contribution!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 30, 2025
## 0.3.0

* Breaking change: fillFileBodyGetNext takes Sentinel instead of
  IO () to close files on time.

## 0.2.1

* Add outBodyCancel to OutBodyIface
  [#11](kazu-yamamoto/http-semantics#11)
* Documentation improvement.
  [#10](kazu-yamamoto/http-semantics#10)
  [#11](kazu-yamamoto/http-semantics#11)

## 0.2.0

* Introduce `responseStreamingIface`
  [#9](kazu-yamamoto/http-semantics#9)

## 0.1.2

* Avoid buffer overflow in fillBufBuilderOne
  [#4](kazu-yamamoto/http-semantics#4)

## 0.1.1

* Avoid buffer overflow in runStreamingBuilder
  [#3](kazu-yamamoto/http-semantics#3)

## 0.1.0

* Make it possible to guarantee that final DATA frame is marked end-of-stream.
  [#2](kazu-yamamoto/http-semantics#2)

## 0.0.1

* Defining getResponseBodyChunk'.
  [#1](kazu-yamamoto/http-semantics#1)
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.

2 participants