summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaetan Rivet <gaetan.rivet@6wind.com>2017-08-04 17:30:23 +0200
committerThomas Monjalon <thomas@monjalon.net>2017-08-04 18:07:26 +0200
commit92ac1d5a13859e5dc65c94aaa94559680f2e26c9 (patch)
tree367ceb1a6a10d6c5927c3798417a8e964efff2b2
parent7d4583558a58a8762c075f8b6af2787421a240cb (diff)
downloaddpdk-92ac1d5a13859e5dc65c94aaa94559680f2e26c9.zip
dpdk-92ac1d5a13859e5dc65c94aaa94559680f2e26c9.tar.gz
dpdk-92ac1d5a13859e5dc65c94aaa94559680f2e26c9.tar.xz
eal: fix hotplug device parsing
snprintf returns the length it would have written had the given length been enough, *terminating null byte excluded*. It will however limit the length of its writing to given length minus one, and always put a terminating null-byte at the end of the string. This must be taken into account when calculating the total length of the device declaration string. Fixes: 3054036f054a ("eal: fix possible crash in hotplug") Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
-rw-r--r--lib/librte_eal/common/eal_common_dev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index fc8a4d2..e251275 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -133,7 +133,7 @@ full_dev_name(const char *bus, const char *dev, const char *args)
char *name;
size_t len;
- len = snprintf(NULL, 0, "%s:%s,%s", bus, dev, args);
+ len = snprintf(NULL, 0, "%s:%s,%s", bus, dev, args) + 1;
name = calloc(1, len);
if (name == NULL) {
RTE_LOG(ERR, EAL, "Could not allocate full device name\n");