DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: fix possible segfault in hotplug add
@ 2017-08-03 12:34 Gaetan Rivet
  2017-08-03 19:38 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Gaetan Rivet @ 2017-08-03 12:34 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

If devargs is NULL, building the full_dev_name will segfault
when using strlen on it.

Coverity issue: 158630
Fixes: 7e8b26650146 ("eal: fix hotplug add / remove")

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index f98302d..d19232d 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -133,16 +133,13 @@ full_dev_name(const char *bus, const char *dev, const char *args)
 	char *name;
 	size_t len;
 
-	len = strlen(bus) + 1 +
-	      strlen(dev) + 1 +
-	      strlen(args) + 1;
+	len = snprintf(NULL, 0, "%s:%s,%s", bus, dev, args);
 	name = calloc(1, len);
 	if (name == NULL) {
 		RTE_LOG(ERR, EAL, "Could not allocate full device name\n");
 		return NULL;
 	}
-	snprintf(name, len, "%s:%s,%s", bus, dev,
-		 args ? args : "");
+	snprintf(name, len, "%s:%s,%s", bus, dev, args);
 	return name;
 }
 
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH] eal: fix possible segfault in hotplug add
  2017-08-03 12:34 [dpdk-dev] [PATCH] eal: fix possible segfault in hotplug add Gaetan Rivet
@ 2017-08-03 19:38 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2017-08-03 19:38 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

03/08/2017 14:34, Gaetan Rivet:
> If devargs is NULL, building the full_dev_name will segfault
> when using strlen on it.
> 
> Coverity issue: 158630
> Fixes: 7e8b26650146 ("eal: fix hotplug add / remove")
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>

Applied, thanks

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

end of thread, other threads:[~2017-08-03 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 12:34 [dpdk-dev] [PATCH] eal: fix possible segfault in hotplug add Gaetan Rivet
2017-08-03 19:38 ` 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).