net/qede: fix strncpy
authorAndy Green <andy@warmcat.com>
Mon, 14 May 2018 05:00:42 +0000 (13:00 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:32:23 +0000 (23:32 +0200)
drivers/net/qede/qede_main.c: In function ‘qed_slowpath_start’:
drivers/net/qede/qede_main.c:307:3: error:
‘strncpy’ output may be truncated copying 12 bytes from a string of length 127
[-Werror=stringop-truncation]
   strncpy((char *)drv_version.name, (const char *)params->name,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    MCP_DRV_VER_STR_SIZE - 4);
    ~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 86a2265e59d7 ("qede: add SRIOV support")
Cc: stable@dpdk.org
Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/qede/qede_main.c

index 2333ca0..ee63ac2 100644 (file)
@@ -9,6 +9,7 @@
 #include <limits.h>
 #include <time.h>
 #include <rte_alarm.h>
+#include <rte_string_fns.h>
 
 #include "qede_ethdev.h"
 
@@ -303,9 +304,8 @@ static int qed_slowpath_start(struct ecore_dev *edev,
                drv_version.version = (params->drv_major << 24) |
                    (params->drv_minor << 16) |
                    (params->drv_rev << 8) | (params->drv_eng);
-               /* TBD: strlcpy() */
-               strncpy((char *)drv_version.name, (const char *)params->name,
-                       MCP_DRV_VER_STR_SIZE - 4);
+               strlcpy((char *)drv_version.name, (const char *)params->name,
+                       sizeof(drv_version.name));
                rc = ecore_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
                                                &drv_version);
                if (rc) {