From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 5/5] examples_ip_pipeline: fix possible string overrun Date: Mon, 31 Aug 2015 18:59:06 -0700 Message-ID: <1441072746-29174-6-git-send-email-stephen@networkplumber.org> References: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org To: cristian.dumitrescu@intel.com Return-path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id 243E08D95 for ; Tue, 1 Sep 2015 03:59:02 +0200 (CEST) Received: by paczk9 with SMTP id zk9so9929677pac.0 for ; Mon, 31 Aug 2015 18:59:01 -0700 (PDT) In-Reply-To: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If a long name was passed the code would clobber memory with strcpy. Signed-off-by: Stephen Hemminger --- 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