All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jastrzebski, MichalX K" <michalx.k.jastrzebski@intel.com>
To: "Piasecki, JacekX" <jacekx.piasecki@intel.com>,
	"Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"Piasecki, JacekX" <jacekx.piasecki@intel.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [PATCH] cfgfile: fix NULL pointer dereference
Date: Fri, 27 Oct 2017 15:08:31 +0000	[thread overview]
Message-ID: <60ABE07DBB3A454EB7FAD707B4BB158213C4B1BF@IRSMSX109.ger.corp.intel.com> (raw)
In-Reply-To: <1508999046-5012-1-git-send-email-jacekx.piasecki@intel.com>

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jacek Piasecki
> Sent: Thursday, October 26, 2017 8:24 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Piasecki, JacekX <jacekx.piasecki@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference
> 
> Function memchr() could return NULL and assign it to split[1] pointer.
> Additional check and error handing is made after memchr() call.
> 
> Coverity issue: 195004
> Fixes: a6a47ac9c2c9 ("cfgfile: rework load function")
> Cc: jacekx.piasecki@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
>  lib/librte_cfgfile/rte_cfgfile.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
> index 124aef5..80077b6 100644
> --- a/lib/librte_cfgfile/rte_cfgfile.c
> +++ b/lib/librte_cfgfile/rte_cfgfile.c
> @@ -241,6 +241,11 @@ rte_cfgfile_load_with_params(const char
> *filename, int flags,
> 
>  			split[0] = buffer;
>  			split[1] = memchr(buffer, '=', len);
> +			if (split[1] == NULL) {
> +				printf("Error line %d - no '='"
> +					"character found\n", lineno);
> +				goto error1;
> +			}
>  			*split[1] = '\0';
>  			split[1]++;
> 
> @@ -268,7 +273,7 @@ rte_cfgfile_load_with_params(const char
> *filename, int flags,
>  				goto error1;
> 
>  			_add_entry(&cfg->sections[cfg->num_sections - 1],
> -					split[0], (split[1] ? split[1] : ""));
> +					split[0], split[1]);
>  		}
>  	}
>  	fclose(f);
> --
> 2.7.4

Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

  reply	other threads:[~2017-10-27 15:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  6:24 [PATCH] cfgfile: fix NULL pointer dereference Jacek Piasecki
2017-10-27 15:08 ` Jastrzebski, MichalX K [this message]
2017-11-07  1:20   ` [dpdk-stable] " Thomas Monjalon

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=60ABE07DBB3A454EB7FAD707B4BB158213C4B1BF@IRSMSX109.ger.corp.intel.com \
    --to=michalx.k.jastrzebski@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jacekx.piasecki@intel.com \
    --cc=stable@dpdk.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.