aboutsummaryrefslogtreecommitdiff
path: root/fsdev
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-03-30 14:57:16 +0100
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2015-06-16 20:32:29 +0530
commitf8d30a4f96d6c3a12e692d2e69b8fe4734b916c6 (patch)
tree7fe882b28651b57e1b2acd8e84b11cd5b453453c /fsdev
parentbf6667d63ef4c4fbaf91051589a594ec1c235308 (diff)
downloadqemu-f8d30a4f96d6c3a12e692d2e69b8fe4734b916c6.zip
qemu-f8d30a4f96d6c3a12e692d2e69b8fe4734b916c6.tar.gz
qemu-f8d30a4f96d6c3a12e692d2e69b8fe4734b916c6.tar.bz2
virtfs-proxy-helper: fail gracefully if socket path is too long
Replace the assertion check with graceful failure when the socket path is too long. Programs should not crash on invalid input. Print an error message and exit properly. Cc: Shannon Zhao <zhaoshenglong@huawei.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'fsdev')
-rw-r--r--fsdev/virtfs-proxy-helper.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 91e8b9b..9097d15 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -739,7 +739,12 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
return -1;
}
- g_assert(strlen(path) < sizeof(proxy.sun_path));
+ if (strlen(path) >= sizeof(proxy.sun_path)) {
+ do_log(LOG_CRIT, "UNIX domain socket path exceeds %zu characters\n",
+ sizeof(proxy.sun_path));
+ return -1;
+ }
+
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
do_perror("socket");