From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 5/5] examples_ip_pipeline: fix possible string overrun
Date: Wed, 9 Sep 2015 18:33:09 +0000 [thread overview]
Message-ID: <3EB4FA525960D640B5BDFFD6A3D89126478B957C@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <1441072746-29174-6-git-send-email-stephen@networkplumber.org>
> -----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
>
> If a long name was passed the code would clobber memory with
> strcpy.
>
> Signed-off-by: Stephen Hemminger <stephen@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';
Could be done, but not necessary, as the pipeline name string was already validated in the parser module; now it is just copied over, and it is safe to assume it of right size.
I don't mind doing it for extra safety.
>
> p_out->socket_id = (int) p_in->socket_id;
>
> --
> 2.1.4
next prev parent reply other threads:[~2015-09-09 18:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 1:59 [dpdk-dev] [PATCH 0/5] fixup ip pipeline examples Stephen Hemminger
2015-09-01 1:59 ` [dpdk-dev] [PATCH 1/5] examples_ip_pipeline: fix typo's Stephen Hemminger
2015-09-09 18:21 ` Dumitrescu, Cristian
2015-09-01 1:59 ` [dpdk-dev] [PATCH 2/5] example_ip_pipeline: avoid strncpy issue Stephen Hemminger
2015-09-09 18:22 ` Dumitrescu, Cristian
2015-09-10 8:44 ` Bruce Richardson
2015-09-01 1:59 ` [dpdk-dev] [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy Stephen Hemminger
2015-09-09 18:25 ` Dumitrescu, Cristian
2015-09-09 18:47 ` Stephen Hemminger
2015-09-01 1:59 ` [dpdk-dev] [PATCH 4/5] examples_ip_pipeline: remove useless code Stephen Hemminger
2015-09-09 18:31 ` Dumitrescu, Cristian
2015-09-01 1:59 ` [dpdk-dev] [PATCH 5/5] examples_ip_pipeline: fix possible string overrun Stephen Hemminger
2015-09-09 18:33 ` Dumitrescu, Cristian [this message]
2015-09-09 18:35 ` [dpdk-dev] [PATCH 0/5] fixup ip pipeline examples Dumitrescu, Cristian
2015-10-07 16:43 ` Thomas Monjalon
2015-10-12 14:51 ` Dumitrescu, Cristian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EB4FA525960D640B5BDFFD6A3D89126478B957C@IRSMSX108.ger.corp.intel.com \
--to=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).