ena: use snprintf instead of strncpy 91/43291/4
authorDamjan Marion <[email protected]>
Wed, 25 Jun 2025 13:09:31 +0000 (15:09 +0200)
committerMohammed HAWARI <[email protected]>
Mon, 30 Jun 2025 13:58:41 +0000 (13:58 +0000)
.. and silence gcc-11

Type: fix
Change-Id: Iad2671baf7d29aa861e74aafe952591e7205732d
Signed-off-by: Damjan Marion <[email protected]>
src/plugins/dev_ena/ena.c

index a81a33d..6e7afaa 100644 (file)
@@ -170,8 +170,9 @@ ena_init (vlib_main_t *vm, vnet_dev_t *dev)
 
   *ed->host_info = host_info;
   ed->host_info->num_cpus = vlib_get_n_threads ();
-  strncpy ((char *) ed->host_info->kernel_ver_str, VPP_BUILD_VER,
-          sizeof (ed->host_info->kernel_ver_str) - 1);
+  snprintf ((char *) ed->host_info->kernel_ver_str,
+           sizeof (ed->host_info->kernel_ver_str), "%.*s",
+           (int) (sizeof (ed->host_info->kernel_ver_str) - 1), VPP_BUILD_VER);
   ena_set_mem_addr (vm, dev, &host_attr.os_info_ba, ed->host_info);
 
   if ((rv = ena_aq_set_feature (vm, dev, ENA_ADMIN_FEAT_ID_HOST_ATTR_CONFIG,