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 possible bugs in HTTP/2 Codec #10640

Merged
merged 5 commits into from Oct 26, 2020
Merged

Fix possible bugs in HTTP/2 Codec #10640

merged 5 commits into from Oct 26, 2020

Conversation

hyperxpro
Copy link
Contributor

@hyperxpro hyperxpro commented Oct 6, 2020

Motivation:

  1. data can be null

    ByteBuf lastFrame = data.readSlice(frameDataBytes);

  2. i >= current.length is always true

    if (i >= current.length && current == pseudoHeaders) {

  3. newValue != 0 is always true

  4. (parentStream == null) is already handled by shouldIgnoreHeadersOrDataFrame(ctx, streamId, parentStream, "PUSH_PROMISE") because it'll throw an error.


  5. for (int i = 0; i < name.length(); ++i) { name can be null because we don't return in null check.


  6. hpackHeaderFields[cursor++]; can be null and it'll throw NPE when we try to access it.

    HpackHeaderField entry = hpackHeaderFields[cursor++];

  7. next = current[i + 1]; can lead to Array Index Out of Bound error.

Modification:
Fixed all the above possible bugs.

Result:
Better code

@netty-bot
Copy link

Can one of the admins verify this patch?

@hyperxpro
Copy link
Contributor Author

HTTP/2 Codec tests passing perfectly.

@hyperxpro
Copy link
Contributor Author

@chrisvest PTAL

@normanmaurer
Copy link
Member

@netty-bot test this please

@chrisvest
Copy link
Contributor

@netty-bot test this please

@hyperxpro
Copy link
Contributor Author

Ready to merge if code looks fine to everyone.

@artem-smotrakov
Copy link
Contributor

@hyperxpro I see you fix some issues reported by LGTM. Would you mind suppressing the warnings that appeared to be false-positives?

https://lgtm.com/help/lgtm/alert-suppression#java

@hyperxpro
Copy link
Contributor Author

@artem-smotrakov I don't think there is any false positive in this.

@normanmaurer normanmaurer added this to the 4.1.54.Final milestone Oct 26, 2020
@normanmaurer normanmaurer merged commit ee3b9a5 into netty:4.1 Oct 26, 2020
normanmaurer pushed a commit that referenced this pull request Oct 26, 2020
)

Motivation:

There are possible NPEs and IndexOutOfBoundsExceptions in HTTP/2 code. 

Modification:
Fixed possible NPEs and IOOBEs

Result:
Better code
@hyperxpro hyperxpro deleted the h2opt branch October 26, 2020 14:12
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…ty#10640)

Motivation:

There are possible NPEs and IndexOutOfBoundsExceptions in HTTP/2 code. 

Modification:
Fixed possible NPEs and IOOBEs

Result:
Better code
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.

None yet

5 participants