vcl: accept zero length writes 06/32606/4
authorFlorin Coras <fcoras@cisco.com>
Sat, 5 Jun 2021 00:31:53 +0000 (17:31 -0700)
committerDave Barach <openvpp@barachs.net>
Mon, 7 Jun 2021 15:24:40 +0000 (15:24 +0000)
Type: fix

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

src/vcl/vppcom.c

index 4c77b0b..0c6f6e6 100644 (file)
@@ -2152,8 +2152,12 @@ vppcom_session_write_inline (vcl_worker_t * wrk, vcl_session_t * s, void *buf,
   svm_msg_q_t *mq;
   u8 is_ct;
 
-  if (PREDICT_FALSE (!buf || n == 0))
-    return VPPCOM_EINVAL;
+  /* Accept zero length writes but just return */
+  if (PREDICT_FALSE (!n))
+    return VPPCOM_OK;
+
+  if (PREDICT_FALSE (!buf))
+    return VPPCOM_EFAULT;
 
   if (PREDICT_FALSE (s->flags & VCL_SESSION_F_IS_VEP))
     {
@@ -2163,7 +2167,7 @@ vppcom_session_write_inline (vcl_worker_t * wrk, vcl_session_t * s, void *buf,
     }
 
   if (PREDICT_FALSE (!vcl_session_is_open (s) ||
-                    s->flags & VCL_SESSION_F_SHUTDOWN))
+                    (s->flags & VCL_SESSION_F_SHUTDOWN)))
     {
       VDBG (1, "session %u [0x%llx]: is not open! state 0x%x (%s)",
            s->session_index, s->vpp_handle, s->session_state,
@@ -3889,12 +3893,9 @@ vppcom_session_sendto (uint32_t session_handle, void *buffer,
   vcl_session_t *s;
 
   s = vcl_session_get_w_handle (wrk, session_handle);
-  if (!s)
+  if (PREDICT_FALSE (!s))
     return VPPCOM_EBADFD;
 
-  if (!buffer)
-    return VPPCOM_EINVAL;
-
   if (ep)
     {
       if (!vcl_session_is_cl (s))