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>
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");