[nginx] HTTP/2: return error on output on closed stream.

Maxim Dounin mdounin at mdounin.ru
Thu Jul 18 15:28:37 UTC 2019


details:   https://hg.nginx.org/nginx/rev/01e26357916a
branches:  
changeset: 7537:01e26357916a
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Jul 18 18:27:50 2019 +0300
description:
HTTP/2: return error on output on closed stream.

Without this, an (incorrect) output on a closed stream could result in
a socket leak.

diffstat:

 src/http/v2/ngx_http_v2_filter_module.c |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (16 lines):

diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c
--- a/src/http/v2/ngx_http_v2_filter_module.c
+++ b/src/http/v2/ngx_http_v2_filter_module.c
@@ -1444,6 +1444,12 @@ ngx_http_v2_send_chain(ngx_connection_t 
 
     if (in == NULL || stream->out_closed) {
 
+        if (size) {
+            ngx_log_error(NGX_LOG_ERR, fc->log, 0,
+                          "output on closed stream");
+            return NGX_CHAIN_ERROR;
+        }
+
         if (stream->queued) {
             fc->write->active = 1;
             fc->write->ready = 0;


More information about the nginx-devel mailing list