From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 405135A35 for ; Wed, 9 Sep 2015 20:33:12 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 09 Sep 2015 11:33:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,498,1437462000"; d="scan'208";a="801683207" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga002.fm.intel.com with ESMTP; 09 Sep 2015 11:33:11 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.12]) by irsmsx110.ger.corp.intel.com ([163.33.3.25]) with mapi id 14.03.0224.002; Wed, 9 Sep 2015 19:33:09 +0100 From: "Dumitrescu, Cristian" To: Stephen Hemminger Thread-Topic: [PATCH 5/5] examples_ip_pipeline: fix possible string overrun Thread-Index: AQHQ5FnMvPFjIyoKuEmXnjBP2nmwAZ40ksJQ Date: Wed, 9 Sep 2015 18:33:09 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D89126478B957C@IRSMSX108.ger.corp.intel.com> References: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> <1441072746-29174-6-git-send-email-stephen@networkplumber.org> In-Reply-To: <1441072746-29174-6-git-send-email-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [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: Wed, 09 Sep 2015 18:33:12 -0000 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Tuesday, September 1, 2015 4:59 AM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org; Stephen Hemminger > Subject: [PATCH 5/5] examples_ip_pipeline: fix possible string overrun >=20 > If a long name was passed the code would clobber memory with > strcpy. >=20 > Signed-off-by: Stephen Hemminger > --- > examples/ip_pipeline/app.h | 2 +- > examples/ip_pipeline/init.c | 5 +++-- > 2 files changed, 4 insertions(+), 3 deletions(-) >=20 > 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 >=20 > struct app_pipeline_params { > - char *name; > + const char *name; > uint8_t parsed; >=20 > 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) > } >=20 > 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; >=20 > - 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] =3D '\0'; Could be done, but not necessary, as the pipeline name string was already v= alidated in the parser module; now it is just copied over, and it is safe t= o assume it of right size. I don't mind doing it for extra safety. >=20 > p_out->socket_id =3D (int) p_in->socket_id; >=20 > -- > 2.1.4