From 7f9de007d0196c7b6a8354902e50b27755936d10 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 21 Feb 2015 21:17:52 +0900 Subject: [PATCH] nghttpx: Fix crash in http/1 backend when backend returns more bytes than CL This is typically programming mistake that we did not check return value before doing another. --- src/shrpx_https_upstream.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 3ca73444..08c832df 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -455,6 +455,14 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) { rv = downstream->on_read(); + if (rv == SHRPX_ERR_EOF) { + return downstream_eof(dconn); + } + + if (rv < 0) { + return downstream_error(dconn, Downstream::EVENT_ERROR); + } + if (downstream->get_response_state() == Downstream::MSG_RESET) { return -1; } @@ -473,14 +481,6 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) { downstream->detach_downstream_connection(); } - if (rv == SHRPX_ERR_EOF) { - return downstream_eof(dconn); - } - - if (rv < 0) { - return downstream_error(dconn, Downstream::EVENT_ERROR); - } - end: handler_->signal_write();