Skip to content

Commit 270fb5c

Browse files
committed
Check error on socket() call
1 parent 1cc15b8 commit 270fb5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/gateway.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ void get_clients_from_parent(void) {
112112
debug(LOG_INFO, "Connecting to parent to download clients");
113113

114114
/* Connect to socket */
115-
sock = socket(AF_UNIX, SOCK_STREAM, 0);
115+
if (-1 == (sock = socket(AF_UNIX, SOCK_STREAM, 0))) {
116+
debug(LOG_ERR, "Failed to create socket (%s)", strerror(errno));
117+
return;
118+
}
116119
memset(&sa_un, 0, sizeof(sa_un));
117120
sa_un.sun_family = AF_UNIX;
118121
strncpy(sa_un.sun_path, config->internal_sock, (sizeof(sa_un.sun_path) - 1));

0 commit comments

Comments
 (0)