vlib: fix vlib_buffer_enqueue_to_next() overflow
[vpp.git] / src / vnet / crypto / node.c
index 63ed95e..e753f1a 100644 (file)
@@ -87,9 +87,9 @@ crypto_dequeue_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
     {
       if (cf)
        {
-         vec_validate (ct->buffer_indice, n_cache + cf->n_elts);
+         vec_validate (ct->buffer_indices, n_cache + cf->n_elts);
          vec_validate (ct->nexts, n_cache + cf->n_elts);
-         clib_memcpy_fast (ct->buffer_indice + n_cache, cf->buffer_indices,
+         clib_memcpy_fast (ct->buffer_indices + n_cache, cf->buffer_indices,
                            sizeof (u32) * cf->n_elts);
          if (cf->state == VNET_CRYPTO_FRAME_STATE_SUCCESS)
            {
@@ -114,8 +114,8 @@ crypto_dequeue_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
          n_cache += cf->n_elts;
          if (n_cache >= VLIB_FRAME_SIZE)
            {
-             vlib_buffer_enqueue_to_next (vm, node, ct->buffer_indice,
-                                          ct->nexts, n_cache);
+             vlib_buffer_enqueue_to_next_vec (vm, node, &ct->buffer_indices,
+                                              &ct->nexts, n_cache);
              n_cache = 0;
            }
 
@@ -138,8 +138,9 @@ crypto_dequeue_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
       if (cm->dispatch_mode == VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
          && n_elts > 0)
        {
-         vlib_node_set_interrupt_pending (vlib_mains[enqueue_thread_idx],
-                                          cm->crypto_node_index);
+         vlib_node_set_interrupt_pending (
+           vlib_get_main_by_index (enqueue_thread_idx),
+           cm->crypto_node_index);
        }
 
       n_elts = 0;
@@ -167,8 +168,8 @@ VLIB_NODE_FN (crypto_dispatch_node) (vlib_main_t * vm,
   }
   /* *INDENT-ON* */
   if (n_cache)
-    vlib_buffer_enqueue_to_next (vm, node, ct->buffer_indice, ct->nexts,
-                                n_cache);
+    vlib_buffer_enqueue_to_next_vec (vm, node, &ct->buffer_indices, &ct->nexts,
+                                    n_cache);
 
   return n_dispatched;
 }