diff options
author | GDR! <gdr@gdr.name> | 2015-07-07 19:30:50 +0200 |
---|---|---|
committer | GDR! <gdr@gdr.name> | 2015-07-07 19:30:50 +0200 |
commit | 7262fd7141bdae8ae15c3f625988a7f26463cdb5 (patch) | |
tree | 95131ec73420df38cf26919bac181e51c7e341e9 /client.c | |
parent | f1826d2061908883fb654059f0675f79396edad0 (diff) |
CID 122499 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN)2. check_return: Calling setsockopt(bind_sockfd, 1, 2,
&yes, 4U) without checking return value. This library function may fail
and return an error code.
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -44,6 +44,7 @@ int local_bind() | |||
44 | int yes = 1; | 44 | int yes = 1; |
45 | int flags; | 45 | int flags; |
46 | int gai_status; | 46 | int gai_status; |
47 | int setsockopt_status; | ||
47 | 48 | ||
48 | snprintf(port, 6, "%d", local_port); | 49 | snprintf(port, 6, "%d", local_port); |
49 | 50 | ||
@@ -67,7 +68,14 @@ int local_bind() | |||
67 | exit(1); | 68 | exit(1); |
68 | } | 69 | } |
69 | 70 | ||
70 | setsockopt(bind_sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); | 71 | setsockopt_status = setsockopt(bind_sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); |
72 | if(setsockopt_status < 0) | ||
73 | { | ||
74 | log_printf(L_ERROR, "Could not set socket options: %s\n", | ||
75 | explain_setsockopt(bind_sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int))); | ||
76 | freeaddrinfo(res); | ||
77 | exit(1); | ||
78 | } | ||
71 | 79 | ||
72 | /* Set O_NONBLOCK to make accept() non-blocking */ | 80 | /* Set O_NONBLOCK to make accept() non-blocking */ |
73 | if (-1 == (flags = fcntl(bind_sockfd, F_GETFL, 0))) | 81 | if (-1 == (flags = fcntl(bind_sockfd, F_GETFL, 0))) |