From 6c33728a3521f9f0abb62f4cab5c8c6f61a72686 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 4 Feb 2022 19:40:26 -0800 Subject: http_static: handle empty requests Type: fix Signed-off-by: Florin Coras Change-Id: Ic002444c51b1ecbbf18a49863cf01888d28c4632 --- src/plugins/http_static/static_server.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/plugins/http_static') diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index bd231b44b47..48a33107926 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -379,6 +379,12 @@ handle_request (hss_session_t *hs, http_req_method_t rt, u8 *request) if (!try_url_handler (hsm, hs, rt, request)) return 0; + if (!hsm->www_root) + { + sc = HTTP_STATUS_NOT_FOUND; + goto done; + } + /* * Construct the file to open * Browsers are capable of sporadically including a leading '/' @@ -609,9 +615,12 @@ hss_ts_rx_callback (session_t *ts) } /* Read request */ - vec_validate (request, msg.data.len - 1); - rv = svm_fifo_dequeue (ts->rx_fifo, msg.data.len, request); - ASSERT (rv == msg.data.len); + if (msg.data.len) + { + vec_validate (request, msg.data.len - 1); + rv = svm_fifo_dequeue (ts->rx_fifo, msg.data.len, request); + ASSERT (rv == msg.data.len); + } /* Find and send data */ handle_request (hs, msg.method_type, request); -- cgit 1.2.3-korg