patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/failsafe: fix parameters parsing
@ 2017-08-17 14:19 Matan Azrad
  2017-08-17 15:25 ` Gaëtan Rivet
  0 siblings, 1 reply; 14+ messages in thread
From: Matan Azrad @ 2017-08-17 14:19 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, Ori Kam, stable

The corrupted code used wrongly snprintf return value as the
number of characters actually copied, in spite of the meanning
is the number of characters which would be generated for the
given input.

It caused to remain zerod bytes between the failsafe command line
non sub device parameters indicates end of string.

Hence, when rte_kvargs_parse tried to parse all parameters, it
got end of string after the first one and the others weren't parsed.

So, if the mac parameters was the first in command line it was
taken while hotplug_poll was left default, and vice versa.

The fix updates the buffer index by dedicated variable contains
the copy size, by the way uses memcpy instead of snprintf
which is good enouth for this copy scenario.

Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/failsafe/failsafe_args.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index 1f22416..0a98b04 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -271,7 +271,7 @@ static int
 fs_remove_sub_devices_definition(char params[DEVARGS_MAXLEN])
 {
 	char buffer[DEVARGS_MAXLEN] = {0};
-	size_t a, b;
+	size_t a, b, temp;
 	int i;
 
 	a = 0;
@@ -286,12 +286,14 @@ fs_remove_sub_devices_definition(char params[DEVARGS_MAXLEN])
 			ERROR("Invalid parameter");
 			return -EINVAL;
 		}
-		if (params[b] == ',' || params[b] == '\0')
-			i += snprintf(&buffer[i], b - a + 1, "%s", &params[a]);
-		if (params[b] == '(') {
-			size_t start = b;
+		if (params[b] == ',' || params[b] == '\0') {
+			temp = b - a + 1;
+			memcpy(&buffer[i], &params[a], temp);
+			i += temp;
+		} else if (params[b] == '(') {
+			temp = b;
 			b += closing_paren(&params[b]);
-			if (b == start)
+			if (b == temp)
 				return -EINVAL;
 			b += 1;
 			if (params[b] == '\0')
-- 
2.7.4

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

end of thread, other threads:[~2017-08-29 17:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17 14:19 [dpdk-stable] [PATCH] net/failsafe: fix parameters parsing Matan Azrad
2017-08-17 15:25 ` Gaëtan Rivet
2017-08-17 15:54   ` Matan Azrad
2017-08-17 16:24     ` Gaëtan Rivet
2017-08-17 18:52       ` Matan Azrad
2017-08-18  9:03         ` Gaëtan Rivet
2017-08-19 21:24           ` Matan Azrad
2017-08-19 22:07             ` [dpdk-stable] [PATCH v2] " Matan Azrad
2017-08-21  9:34               ` Gaëtan Rivet
2017-08-21 12:02                 ` Matan Azrad
2017-08-21 13:25                   ` Gaëtan Rivet
2017-08-27  7:23                     ` [dpdk-stable] [PATCH v3] " Matan Azrad
2017-08-28  7:52                       ` Gaëtan Rivet
2017-08-29 17:05                         ` Ferruh Yigit

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