GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Prevent leaking a ByteBuf during http2->http1 conversion by jguerra · Pull Request #18254 · netty/netty

Conversation

@jguerra

@jguerra jguerra commented Nov 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Motivation:

Http2StreamFrameToHttpObjectCodec can leak a ByteBuf when converting http2 headers to a FullHttpRequest. For example, if the http2 headers are missing a :path or :method contains an illegal character, HttpConversionUtil.toFullHttpRequest will throw an exception without releasing the content passed in

Modification:

I moved the validation logic in HttpConversionUtil.toFullHttpRequest() and HttpConversionUtil.toFullHttpResponse() into the existing try/catch, and modified the release to operate on the ByteBuf instead of the request/response msg. As a result of this, the exception thrown for different types of validation errors changes. Previously, a missing :path header would throw a NPE, while an illegal method would throw an IllegalArgumentException. With my changes these errors are now wrapped in a Http2Exception. Because of this, I also modified toHttpRequest() and toHttpResponse() to have consistent exception types, even though they have no risk of leaking memory.

Result:

  • Http2StreamFrameToHttpObjectCodec no longer leaks a ByteBuf on invalid http2 headers
  • Validation errors during http2 -> http1 conversion are now wrapped in a Http2Exception

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gavinbunney reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@jguerra
Prevent leaking buffer during http2->http1 conversion
d829a5d
@jguerra

jguerra commented Nov 16, 2026

Copy link
Copy Markdown
Author

@normanmaurer can you consider this one for the next release? 🙏 In the proxy I work on get a fair amount of spurious leak reports due to this issue

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
Merge branch '4.2' into jg/http_conversion_leak
45c84b4
@normanmaurer normanmaurer added this to the 4.2.22.Final milestone Nov 24, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 24, 2026
@testlens-app

testlens-app Bot commented Nov 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚨 All tests passed but jobs failed 🚨

Failed Jobs without Test Failures

❌ Build PR / linux-x86_64-java11-awslc build

🏷️ Commit: 45c84b4
▶️ Tests: 52300 executed
⚪️ Checks: 30/30 completed

Rerun Controls

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer requested changes Nov 27, 2026
View reviewed changes
Comment thread codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java
addHttp2ToHttpHeaders(streamId, http2Headers, msg, false);
} catch (Http2Exception e) {
msg.release();
content.release();

@normanmaurer normanmaurer Nov 27, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this is not correct... I think it would be more correct to release the msg if its not null and only if its null release content. While it makes no difference in practice I think it's still more correct and future proof. Same goes for the other places.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged.

Projects

None yet

Milestone

4.2.22.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jguerra @normanmaurer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.