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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can one of the admins verify this patch? |
HTTP/2 Codec tests passing perfectly. |
@chrisvest PTAL |
@netty-bot test this please |
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Outdated
Show resolved
Hide resolved
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Outdated
Show resolved
Hide resolved
normanmaurer
requested changes
Oct 12, 2020
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Outdated
Show resolved
Hide resolved
codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java
Show resolved
Hide resolved
@netty-bot test this please |
Ready to merge if code looks fine to everyone. |
@hyperxpro I see you fix some issues reported by LGTM. Would you mind suppressing the warnings that appeared to be false-positives? |
@artem-smotrakov I don't think there is any false positive in this. |
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
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.
Motivation:
data
can benull
netty/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2FrameWriter.java
Line 224 in 69b44c6
i >= current.length
is alwaystrue
netty/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java
Line 831 in 69b44c6
newValue != 0
is alwaystrue
netty/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java
Line 261 in 69b44c6
(parentStream == null)
is already handled byshouldIgnoreHeadersOrDataFrame(ctx, streamId, parentStream, "PUSH_PROMISE")
because it'll throw an error.netty/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java
Line 510 in 69b44c6
netty/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionDecoder.java
Line 582 in 69b44c6
for (int i = 0; i < name.length(); ++i) {
name can benull
because we don't return innull
check.netty/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Line 65 in 69b44c6
netty/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Line 43 in 69b44c6
hpackHeaderFields[cursor++];
can benull
and it'll throw NPE when we try to access it.netty/codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDynamicTable.java
Line 188 in 69b44c6
next = current[i + 1];
can lead to Array Index Out of Bound error.netty/codec-http2/src/main/java/io/netty/handler/codec/http2/ReadOnlyHttp2Headers.java
Line 826 in 69b44c6
Modification:
Fixed all the above possible bugs.
Result:
Better code