[PATCH 02 of 10] HTTP/2: improved window updates checking
Maxim Dounin
mdounin at mdounin.ru
Tue Nov 24 00:27:05 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1795479766 -10800
# Tue Nov 24 03:22:46 2026 +0300
# Node ID a793fa576435e45acbbfc92fb3294836120bf2af
# Parent 8e67e5a054a991801d1f3de376c7c2c7699cf932
HTTP/2: improved window updates checking.
Window updates are now rejected as long as the current send window is
larger than NGX_HTTP_V2_MAX_WINDOW minus the window update sent by the
client, so no overflows or underflows are possible. Additionally, the
check on the window update itself ensures it is no larger than the
maximum (which is not possible per protocol, so the check is provided
for clarity).
This ensures that window updates are properly rejected even if the
current send window happens to be larger than NGX_HTTP_V2_MAX_WINDOW for
some reason.
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -2491,8 +2491,10 @@ ngx_http_v2_state_window_update(ngx_http
stream = node->stream;
- if (window > (size_t) (NGX_HTTP_V2_MAX_WINDOW - stream->send_window)) {
-
+ if (window > NGX_HTTP_V2_MAX_WINDOW
+ || stream->send_window
+ > (ssize_t) (NGX_HTTP_V2_MAX_WINDOW - window))
+ {
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
"client violated flow control for stream %ui: "
"received WINDOW_UPDATE frame "
@@ -2529,7 +2531,9 @@ ngx_http_v2_state_window_update(ngx_http
return ngx_http_v2_state_complete(h2c, pos, end);
}
- if (window > NGX_HTTP_V2_MAX_WINDOW - h2c->send_window) {
+ if (window > NGX_HTTP_V2_MAX_WINDOW
+ || h2c->send_window > NGX_HTTP_V2_MAX_WINDOW - window)
+ {
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
"client violated connection flow control: "
"received WINDOW_UPDATE frame "
More information about the nginx-devel
mailing list