[dpdk-dev,1/3] vhost: fix malloc in rte_vhost_get_mem_table
Checks
Commit Message
Amount of allocated memory was too small, causing buffer overflow.
Change-Id: I02293cd4bcddef14d2bbf314c79d8c65fc44e555
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
---
lib/librte_vhost/vhost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -369,7 +369,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
return -1;
size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region);
- m = malloc(size);
+ m = malloc(sizeof(struct rte_vhost_memory) + size);
if (!m)
return -1;