Skip to content

Commit 4c3c670

Browse files
committed
Check return value of socket()
1 parent f4672ed commit 4c3c670

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/wdctl_thread.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ thread_wdctl(void *arg)
100100
debug(LOG_DEBUG, "Creating socket");
101101
wdctl_socket_server = socket(PF_UNIX, SOCK_STREAM, 0);
102102

103+
if (wdctl_socket_server < 0) {
104+
debug(LOG_DEBUG, "Could not get server socket: %s", strerror(errno));
105+
pthread_exit(NULL);
106+
}
103107
debug(LOG_DEBUG, "Got server socket %d", wdctl_socket_server);
104108

105109
/* If it exists, delete... Not the cleanest way to deal. */
@@ -292,6 +296,10 @@ wdctl_restart(int afd)
292296
debug(LOG_DEBUG, "Creating socket");
293297
sock = socket(PF_UNIX, SOCK_STREAM, 0);
294298

299+
if (sock < 0) {
300+
debug(LOG_DEBUG, "Could not get server socket: %s", strerror(errno));
301+
pthread_exit(NULL);
302+
}
295303
debug(LOG_DEBUG, "Got internal socket %d", sock);
296304

297305
/* If it exists, delete... Not the cleanest way to deal. */

0 commit comments

Comments
 (0)