DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference
@ 2017-10-26  6:24 Jacek Piasecki
  2017-10-27 15:08 ` Jastrzebski, MichalX K
  0 siblings, 1 reply; 3+ messages in thread
From: Jacek Piasecki @ 2017-10-26  6:24 UTC (permalink / raw)
  To: cristian.dumitrescu; +Cc: dev, Jacek Piasecki, stable

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference
  2017-10-26  6:24 [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference Jacek Piasecki
@ 2017-10-27 15:08 ` Jastrzebski, MichalX K
  2017-11-07  1:20   ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Jastrzebski, MichalX K @ 2017-10-27 15:08 UTC (permalink / raw)
  To: Piasecki, JacekX, Dumitrescu, Cristian; +Cc: dev, Piasecki, JacekX, stable

> -----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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH] cfgfile: fix NULL pointer dereference
  2017-10-27 15:08 ` Jastrzebski, MichalX K
@ 2017-11-07  1:20   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-11-07  1:20 UTC (permalink / raw)
  To: Piasecki, JacekX; +Cc: Jastrzebski, MichalX K, Dumitrescu, Cristian, dev

27/10/2017 17:08, Jastrzebski, MichalX K:
> > 
> > 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

No need to Cc stable for bugs introduced in current release.

> > Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> 
> Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-07  1:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26  6:24 [dpdk-dev] [PATCH] cfgfile: fix NULL pointer dereference Jacek Piasecki
2017-10-27 15:08 ` Jastrzebski, MichalX K
2017-11-07  1:20   ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon

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).