From 704bbbfcaae753c46917948ba1e9655201aee01a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 8 Aug 2014 23:08:24 +0900 Subject: [PATCH] nghttpx: Fail if :status is not digits on http2 downstream --- src/shrpx_http2_session.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 927bc58a..da4f6087 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -921,7 +921,11 @@ int on_response_headers(Http2Session *http2session, } auto status = http2::get_unique_header(nva, ":status"); - if(!status || http2::value_lws(status)) { + int status_code; + + if(!status || http2::value_lws(status) || + (status_code = http2::parse_http_status_code(status->value)) == -1) { + http2session->submit_rst_stream(frame->hd.stream_id, NGHTTP2_PROTOCOL_ERROR); downstream->set_response_state(Downstream::MSG_RESET); @@ -930,8 +934,7 @@ int on_response_headers(Http2Session *http2session, return 0; } - downstream->set_response_http_status(strtoul(status->value.c_str(), - nullptr, 10)); + downstream->set_response_http_status(status_code); downstream->set_response_major(2); downstream->set_response_minor(0);