don't call connect() on negative socket

Coverity CID 405037
This commit is contained in:
Damien Miller 2023-03-31 14:17:22 +11:00
parent 34ee842cdd
commit a4c1c2513e
No known key found for this signature in database

View File

@ -5045,8 +5045,10 @@ connect_local_xsocket_path(const char *pathname)
struct sockaddr_un addr;
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock == -1)
if (sock == -1) {
error("socket: %.100s", strerror(errno));
return -1;
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strlcpy(addr.sun_path, pathname, sizeof addr.sun_path);