diff mbox

[v2] hw/9pfs/virtio-9p-proxy: Fix possible overflow

Message ID 1426298353-8628-1-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao March 14, 2015, 1:59 a.m. UTC
It's detected by coverity. As max of sockaddr_un.sun_path is
sizeof(helper.sun_path), should check the length of source
and use strncpy instead of strcpy.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
    v1->v2: Still use strcpy [Paolo]
---
 hw/9pfs/virtio-9p-proxy.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 59c7445..5ebfaf6 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -1102,6 +1102,7 @@  static int connect_namedsocket(const char *path)
     int sockfd, size;
     struct sockaddr_un helper;
 
+    g_assert(strlen(path) < sizeof(helper.sun_path));
     sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
     if (sockfd < 0) {
         fprintf(stderr, "failed to create socket: %s\n", strerror(errno));