[dpdk-dev] [PATCH 5/5] examples_ip_pipeline: fix possible string overrun

Stephen Hemminger stephen at networkplumber.org
Tue Sep 1 03:59:06 CEST 2015


If a long name was passed the code would clobber memory with
strcpy.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 examples/ip_pipeline/app.h  | 2 +-
 examples/ip_pipeline/init.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
index 521e3a0..1f6bf0c 100644
--- a/examples/ip_pipeline/app.h
+++ b/examples/ip_pipeline/app.h
@@ -190,7 +190,7 @@ struct app_pktq_out_params {
 #define APP_MAX_PIPELINE_ARGS                    PIPELINE_MAX_ARGS
 
 struct app_pipeline_params {
-	char *name;
+	const char *name;
 	uint8_t parsed;
 
 	char type[APP_PIPELINE_TYPE_SIZE];
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 75e3767..007af83 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1022,12 +1022,13 @@ app_init_msgq(struct app_params *app)
 }
 
 static void app_pipeline_params_get(struct app_params *app,
-	struct app_pipeline_params *p_in,
+	const struct app_pipeline_params *p_in,
 	struct pipeline_params *p_out)
 {
 	uint32_t i;
 
-	strcpy(p_out->name, p_in->name);
+	strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE - 1);
+	p_out->name[PIPELINE_NAME_SIZE - 1] = '\0';
 
 	p_out->socket_id = (int) p_in->socket_id;
 
-- 
2.1.4



More information about the dev mailing list