GUACAMOLE-513: Handle cases where socket open fails.
This commit is contained in:
parent
9ca382e2aa
commit
30bbb892db
@ -93,6 +93,12 @@ static ssize_t __guac_wol_send_packet(const char* broadcast_addr,
|
||||
if (wol_dest.sin_family == AF_INET) {
|
||||
int wol_bcast = 1;
|
||||
wol_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
/* If opening a socket fails, bail out. */
|
||||
if (wol_socket < 0) {
|
||||
close(wol_socket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Attempt to set broadcast; exit with error if this fails. */
|
||||
if (setsockopt(wol_socket, SOL_SOCKET, SO_BROADCAST, &wol_bcast,
|
||||
@ -106,6 +112,12 @@ static ssize_t __guac_wol_send_packet(const char* broadcast_addr,
|
||||
else {
|
||||
wol_socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
||||
/* If opening the socket fails, bail out. */
|
||||
if (wol_socket < 0) {
|
||||
close(wol_socket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Stick to a single hop for now. */
|
||||
int hops = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user