http hsa: avoid extra space in request 97/35097/2
authorFlorin Coras <fcoras@cisco.com>
Tue, 25 Jan 2022 19:41:58 +0000 (11:41 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 25 Jan 2022 19:31:33 +0000 (19:31 +0000)
Type: improvement

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

src/plugins/hs_apps/http_server.c
src/plugins/http/http.c

index e7d7ad3..7a4a519 100644 (file)
@@ -226,7 +226,7 @@ http_cli_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
 
   /* Replace slashes with spaces, stop at the end of the path */
   i = 0;
-  while (1)
+  while (i < vec_len (request))
     {
       if (request[i] == '/')
        request[i] = ' ';
@@ -237,13 +237,6 @@ http_cli_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
          break;
        }
       i++;
-      /* Should never happen */
-      if (i == vec_len (request))
-       {
-         char *msg = "Bad CLI";
-         vec_validate_init_c_string (html, msg, strlen (msg));
-         goto send;
-       }
     }
 
   /* Generate the html header */
@@ -259,8 +252,6 @@ http_cli_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
   html = format (html, "%v", reply);
   html = format (html, html_footer);
 
-send:
-
   /* Send it */
   rpc_args = clib_mem_alloc (sizeof (*args));
   clib_memcpy_fast (rpc_args, args, sizeof (*args));
index 0868027..705af9a 100644 (file)
@@ -418,13 +418,13 @@ state_wait_method (http_conn_t *hc, transport_send_params_t *sp)
          goto error;
        }
 
-      len = i - hc->rx_buf_offset;
+      len = i - hc->rx_buf_offset - 1;
     }
   else if ((i = v_find_index (hc->rx_buf, 0, "POST ")) >= 0)
     {
       hc->method = HTTP_REQ_POST;
       hc->rx_buf_offset = i + 6;
-      len = vec_len (hc->rx_buf) - hc->rx_buf_offset;
+      len = vec_len (hc->rx_buf) - hc->rx_buf_offset - 1;
     }
   else
     {