examples/ip_pipeline: fix buffer not null terminated
PATCH 1/1 examples/ip_pipeline: fix buffer not null terminated
The destination string may not have a null termination if the source string's length is equal to the sizeof(tap->name).
Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272603
Fixes 2f74ae28e23f ("examples/ip_pipeline: add tap object")
Signed-off-by Jasvinder Singh <[email protected]>
--- examples/ip_pipeline/tap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
examples/ip_pipeline/tap.c +3 -1
@@ -15,6 +15,8 @@#include <string.h> #include <unistd.h> +#include <rte_string_fns.h> +#include "tap.h" #define TAP_DEV "/dev/net/tun"
@@ -85,7 +87,7 @@ tap_create(const char *name)return NULL ;/* Node fill in */ -strncpy (tap->name, name,sizeof (tap->name)); +strlcpy (tap->name, name,sizeof (tap->name)); tap->fd = fd;/* Node add to list */
Signature · 1 line
2.9.3
Quoted 10 lines · Jasvinder Singh
The destination string may not have a null termination if the source string's length is equal to the
sizeof(tap->name).Fix by replacing strncpy with strlcpy that guarantees NULL-termination.
Coverty issue: 272603
Fixes 2f74ae28e23f ("examples/ip_pipeline: add tap object")Signed-off-by Jasvinder Singh <[email protected]>---
Acked-by Bruce Richardson <[email protected]>