diff mbox series

[v2,2/2] eal: fix build with gcc 9.0

Message ID 20181102190606.48279-2-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series [v2,1/2] bus/dpaa: fix build with gcc 9.0 | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Nov. 2, 2018, 7:06 p.m. UTC
build error:
In function ‘eal_plugin_add’,
    .../lib/librte_eal/common/eal_common_options.c:225:2:
    error: ‘strncpy’ output may be truncated copying 4095 bytes from a
           string of length 4095 [-Werror=stringop-truncation]
    strncpy(solib->name, path, PATH_MAX-1);

strncpy may result a not null-terminated string,
replaced it with strlcpy

Fixes: fa9cdc6f8410 ("eal: move plugin loading from linuxapp to common")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2:
* s/rte_strscpy/strlcpy/
---
 lib/librte_eal/common/eal_common_options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Monjalon Nov. 4, 2018, 9:38 p.m. UTC | #1
02/11/2018 20:06, Ferruh Yigit:
> build error:
> In function ‘eal_plugin_add’,
>     .../lib/librte_eal/common/eal_common_options.c:225:2:
>     error: ‘strncpy’ output may be truncated copying 4095 bytes from a
>            string of length 4095 [-Werror=stringop-truncation]
>     strncpy(solib->name, path, PATH_MAX-1);
> 
> strncpy may result a not null-terminated string,
> replaced it with strlcpy
> 
> Fixes: fa9cdc6f8410 ("eal: move plugin loading from linuxapp to common")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Series applied, thanks
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index b82f3ddd1..e31eca5c0 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -222,7 +222,7 @@  eal_plugin_add(const char *path)
 		return -1;
 	}
 	memset(solib, 0, sizeof(*solib));
-	strncpy(solib->name, path, PATH_MAX-1);
+	strlcpy(solib->name, path, PATH_MAX-1);
 	solib->name[PATH_MAX-1] = 0;
 	TAILQ_INSERT_TAIL(&solib_list, solib, next);