QGrpcHttp2Channel: add a configurable maximum metadata size
QtGrpc placed no limit on the metadata received from a server, so a
misbehaving or malicious peer could send unbounded response headers and
exhaust client memory (availability / DoS).
Add QGrpcChannelOptions::setMaximumMetadataSize() to bound an incoming
header block. The limit is advertised as the HTTP/2
SETTINGS_MAX_HEADER_LIST_SIZE parameter and enforced by QHttp2Connection
as the block is received, so an oversized block is rejected before it is
fully buffered. It defaults to 16 KiB (matching gRPC), is floored at 4
KiB so the mandatory protocol headers are never rejected, and is clamped
to the 32-bit transport maximum.
The environment variable QT_GRPC_MAXIMUM_METADATA_SIZE provides a global
override useful for operational purposes and backporting without API
changes. It is sampled once at channel construction to avoid acquiring
qEnvironmentVariable's global lock on a hot path.
Backport to older branches manually: pick the default
SETTINGS_MAX_HEADER_LIST_SIZE advertisement and the environment variable,
without the QGrpcChannelOptions API. The receive-side enforcement lives
in QtNetwork (QTBUG-147564) and must be present on the target branch.
[ChangeLog][QtGrpc][QGrpcChannelOptions] Added setMaximumMetadataSize()
to limit the size of metadata received from a server. The default is
16 KiB, matching the gRPC specification. The environment variable
QT_GRPC_MAXIMUM_METADATA_SIZE provides a global override without
requiring code changes.
Task-number: QTBUG-147564
Fixes: QTBUG-147563
Change-Id: I515230205da1bdf0886d76799649dd007619091f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>