提交 f8d30a4f 编写于 作者: S Stefan Hajnoczi 提交者: Aneesh Kumar K.V

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: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
上级 bf6667d6
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册