From: Jon Loeliger Date: Tue, 27 Feb 2018 19:58:47 +0000 (-0600) Subject: memif: Fix a message initialization problem in VAT X-Git-Tag: v18.04-rc1~242 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F10848%2F2;p=vpp.git memif: Fix a message initialization problem in VAT The VAT calls to MEMIF_SOCKET_FILENAME_ADD_DEL erroneously cleared the message memory after the M() macro call and thus lost their message id. Don't do that. While in the neighborhood, prevent a string copy from referencing data that doesn't belong to the filename string. Change-Id: Ib4309608ed617ef4f193880ecf4a0b35fda65e51 Signed-off-by: Jon Loeliger --- diff --git a/src/plugins/memif/memif_test.c b/src/plugins/memif/memif_test.c index b1d563218d9..510462ef6a8 100644 --- a/src/plugins/memif/memif_test.c +++ b/src/plugins/memif/memif_test.c @@ -164,11 +164,10 @@ api_memif_socket_filename_add_del (vat_main_t * vam) M (MEMIF_SOCKET_FILENAME_ADD_DEL, mp); - memset (mp, 0, sizeof (*mp)); mp->is_add = is_add; mp->socket_id = htonl (socket_id); - memcpy (mp->socket_filename, - socket_filename, sizeof (mp->socket_filename) - 1); + strncpy ((char *) mp->socket_filename, + (char *) socket_filename, sizeof (mp->socket_filename) - 1); vec_free (socket_filename);