The corrupted code used wrongly snprintf return value as the
number of characters actually copied, in spite of the meaning
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 validates the comma separation.
Fixes:
a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
ERROR("Invalid parameter");
return -EINVAL;
}
- if (params[b] == ',' || params[b] == '\0')
- i += snprintf(&buffer[i], b - a + 1, "%s", ¶ms[a]);
- if (params[b] == '(') {
+ if (params[b] == ',' || params[b] == '\0') {
+ size_t len = b - a;
+
+ if (i > 0)
+ len += 1;
+ snprintf(&buffer[i], len + 1, "%s%s",
+ i ? "," : "", ¶ms[a]);
+ i += len;
+ } else if (params[b] == '(') {
size_t start = b;
+
b += closing_paren(¶ms[b]);
if (b == start)
return -EINVAL;
&dev->data->mac_addrs[0]);
if (ret < 0)
goto free_kvlist;
+
mac_from_arg = 1;
}
}