While sending headers and trailers in the normal flow, gRPC ensures that the headers length is less than the limit specified by the peer. If not, a RST_STREAM frame is sent instead.
|
success, err := t.controlBuf.executeAndPut(func() bool { |
|
return t.checkForHeaderListSize(trailingHeader) |
|
}, nil) |
|
if !success { |
|
if err != nil { |
|
return err |
|
} |
|
t.closeStream(s, true, http2.ErrCodeInternal, false) |
|
return ErrHeaderListSizeLimitViolation |
|
} |
|
// Send a RST_STREAM after the trailers if the client has not already half-closed. |
|
rst := s.getState() == streamActive |
|
t.finishStream(s, rst, http2.ErrCodeNo, trailingHeader, true) |
|
success, err := t.controlBuf.executeAndPut(func() bool { return t.checkForHeaderListSize(hf) }, hf) |
|
if !success { |
|
if err != nil { |
|
return err |
|
} |
|
t.closeStream(s, true, http2.ErrCodeInternal, false) |
|
return ErrHeaderListSizeLimitViolation |
|
} |
A similar check should also be performed when the server decides to abort the stream after parsing the client headers here:
|
} |
|
|
|
if err := l.writeHeader(eas.streamID, true, headerFields, nil); err != nil { |
|
return err |
|
} |
We should also add a test to catch regressions.
While sending headers and trailers in the normal flow, gRPC ensures that the headers length is less than the limit specified by the peer. If not, a RST_STREAM frame is sent instead.
grpc-go/internal/transport/http2_server.go
Lines 1113 to 1125 in ae4bd1e
grpc-go/internal/transport/http2_server.go
Lines 1044 to 1051 in ae4bd1e
A similar check should also be performed when the server decides to abort the stream after parsing the client headers here:
grpc-go/internal/transport/controlbuf.go
Lines 855 to 859 in ae4bd1e
We should also add a test to catch regressions.