[dpdk-dev] [PATCH 2/5] example_ip_pipeline: avoid strncpy issue
Stephen Hemminger
stephen at networkplumber.org
Tue Sep 1 03:59:03 CEST 2015
If name is so long that it fills buffer, then string would not
be null terminated.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
examples/ip_pipeline/config_parse_tm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/examples/ip_pipeline/config_parse_tm.c b/examples/ip_pipeline/config_parse_tm.c
index 84702b0..4a35715 100644
--- a/examples/ip_pipeline/config_parse_tm.c
+++ b/examples/ip_pipeline/config_parse_tm.c
@@ -354,7 +354,9 @@ tm_cfgfile_load_sched_subport(
profile = atoi(entries[j].value);
strncpy(name,
entries[j].name,
- sizeof(name));
+ CFG_NAME_LEN - 1);
+ name[CFG_NAME_LEN-1] = '\0';
+
n_tokens = rte_strsplit(
&name[sizeof("pipe")],
strnlen(name, CFG_NAME_LEN),
--
2.1.4
More information about the dev
mailing list