Skip to content

Commit a1cdee3

Browse files
committed
Check return value of socket
1 parent 5481fdf commit a1cdee3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wdctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ connect_to_server(const char *sock_name)
153153

154154
/* Connect to socket */
155155
sock = socket(AF_UNIX, SOCK_STREAM, 0);
156+
if (sock < 0) {
157+
fprintf(stderr, "wdctl: could not get socket (Error: %s)\n", strerror(errno));
158+
exit(1);
159+
}
156160
memset(&sa_un, 0, sizeof(sa_un));
157161
sa_un.sun_family = AF_UNIX;
158162
strncpy(sa_un.sun_path, sock_name, (sizeof(sa_un.sun_path) - 1));

0 commit comments

Comments
 (0)