memif: fix max number of rings
[vpp.git] / extras / libmemif / src / socket.c
index e8b14c9..3982c96 100644 (file)
@@ -107,7 +107,7 @@ memif_msg_send_hello (int fd)
   msg.type = MEMIF_MSG_TYPE_HELLO;
   h->min_version = MEMIF_VERSION;
   h->max_version = MEMIF_VERSION;
-  h->max_s2m_ring = MEMIF_MAX_M2S_RING;
+  h->max_s2m_ring = MEMIF_MAX_S2M_RING;
   h->max_m2s_ring = MEMIF_MAX_M2S_RING;
   h->max_region = MEMIF_MAX_REGION;
   h->max_log2_ring_size = MEMIF_MAX_LOG2_RING_SIZE;
@@ -530,7 +530,7 @@ memif_msg_receive_add_ring (memif_connection_t * c, memif_msg_t * msg, int fd)
       mq =
        (memif_queue_t *) realloc (c->rx_queues,
                                   sizeof (memif_queue_t) * (ar->index + 1));
-      memset (mq, 0, sizeof (memif_queue_t) * (ar->index + 1));
+      memset (mq + ar->index, 0, sizeof (memif_queue_t));
       if (mq == NULL)
        return memif_syscall_error_handler (errno);
       c->rx_queues = mq;
@@ -550,7 +550,7 @@ memif_msg_receive_add_ring (memif_connection_t * c, memif_msg_t * msg, int fd)
       mq =
        (memif_queue_t *) realloc (c->tx_queues,
                                   sizeof (memif_queue_t) * (ar->index + 1));
-      memset (mq, 0, sizeof (memif_queue_t) * (ar->index + 1));
+      memset (mq + ar->index, 0, sizeof (memif_queue_t));
       if (mq == NULL)
        return memif_syscall_error_handler (errno);
       c->tx_queues = mq;