net/virtio-user: fix string overflow
authorJianfeng Tan <jianfeng.tan@intel.com>
Wed, 29 Jun 2016 09:05:34 +0000 (09:05 +0000)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Tue, 5 Jul 2016 11:30:24 +0000 (13:30 +0200)
commit80ceb374e23a993b43628ab8437fce8d720f52fb
treebb444fd4938d48f96f1c73a1fcd6ff30ca5599d5
parent404bd6bfe360ce052aad7953ab3fc3ab995c21e8
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>
drivers/net/virtio/virtio_user/vhost_user.c