http_static: handle empty requests 21/35221/3
authorFlorin Coras <fcoras@cisco.com>
Sat, 5 Feb 2022 03:40:26 +0000 (19:40 -0800)
committerDave Barach <openvpp@barachs.net>
Sat, 5 Feb 2022 21:20:29 +0000 (21:20 +0000)
Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ic002444c51b1ecbbf18a49863cf01888d28c4632

src/plugins/http_static/static_server.c

index bd231b4..48a3310 100644 (file)
@@ -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);