Skip to content

Commit 16ff01b

Browse files
authored
Merge pull request #89 from TERESH1/create_inet_stream_socket-close-fix
Fix possible double close and closing uninitialized fd in create_inet_stream_socket
2 parents 1a4480a + c50a49f commit 16ff01b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

C/inet/libinetsocket.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static inline signed int check_error(int return_value) {
152152
*/
153153
int create_inet_stream_socket(const char *host, const char *service,
154154
char proto_osi3, int flags) {
155-
int sfd, return_value;
155+
int sfd = -1, return_value;
156156
struct addrinfo hint, *result, *result_check;
157157
#ifdef VERBOSE
158158
const char *errstring;
@@ -207,6 +207,7 @@ int create_inet_stream_socket(const char *host, const char *service,
207207
break;
208208

209209
close(sfd);
210+
sfd = -1;
210211
}
211212

212213
// We do now have a working socket STREAM connection to our target

0 commit comments

Comments
 (0)