From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n7grVrPX7+s5jqYfKeRC/QnfUHVHiHH+1T2gbrM10ZI=; b=dxwXEW61K8/XM0VVKxqsFuStu8eWxI76PPm7gPnVpsFTR1OW8fGikCib7Rt+MakUOI YKXB5RN4qQgVYGwdqbpRWmcRoI0GSDwTwyLhwqYdkXivxjp0/uNjIhVOSMAbeuUZwHsP T1wjBrli6yTn+Z/gq3f6zR/7MuFYzKNaabPETBQ7WZH0XHfrKvC+Cp9tGnXECiQ7qrXC 8/Tg97vJimxQ/0CgojeBMfOuOB/ARyBfBdjQPMuH8c1EUBaW39jI2viQPA0PmmbsW1fW IZKvsXDNptxOAiuBnjEvL4Q0Gs1M+vpJLdCeQOlBcFV265dwTfvi4cmYMGilFokBR2E5 eOhA== X-Gm-Message-State: ALoCoQkV7VKEn8ebS1ZCviFRJBaa0QDjafoG+e6GReiroK477EuDuTCBPtQQszT6bndPemFsmT2L X-Received: by 10.68.181.34 with SMTP id dt2mr41852419pbc.7.1441072741528; Mon, 31 Aug 2015 18:59:01 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ld8sm15988418pbc.61.2015.08.31.18.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 18:59:00 -0700 (PDT) From: Stephen Hemminger To: cristian.dumitrescu@intel.com Date: Mon, 31 Aug 2015 18:59:06 -0700 Message-Id: <1441072746-29174-6-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> References: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH 5/5] examples_ip_pipeline: fix possible string overrun X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 01:59:02 -0000 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