summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJianfeng Tan <jianfeng.tan@intel.com>2016-06-29 09:05:34 +0000
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-07-05 13:30:24 +0200
commit80ceb374e23a993b43628ab8437fce8d720f52fb (patch)
treebb444fd4938d48f96f1c73a1fcd6ff30ca5599d5 /drivers
parent404bd6bfe360ce052aad7953ab3fc3ab995c21e8 (diff)
downloaddpdk-80ceb374e23a993b43628ab8437fce8d720f52fb.zip
dpdk-80ceb374e23a993b43628ab8437fce8d720f52fb.tar.gz
dpdk-80ceb374e23a993b43628ab8437fce8d720f52fb.tar.xz
net/virtio-user: fix string overflow
When parsing /proc/self/maps to get hugepage information, the string was being copied with strcpy(), which could, theoretically but in fact not possiblly, overflow the destination buffer. Anyway, to avoid the false alarm, we replaced strncpy with snprintf for safely copying the strings. Coverity issue: 127484 Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer") Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio/virtio_user/vhost_user.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a159ece..082e821 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -181,7 +181,7 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max)
}
huges[idx].addr = v_start;
huges[idx].size = v_end - v_start;
- strcpy(huges[idx].path, tmp);
+ snprintf(huges[idx].path, PATH_MAX, "%s", tmp);
idx++;
}