Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
issue #6: Socket leakage on acceot_socket
Browse files Browse the repository at this point in the history
Hold up the same error checking standards as its owner :)
  • Loading branch information
NathanFrench committed May 22, 2017
1 parent d13b72b commit 18f7ec0
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ htp_log_connection(evhtp_connection_t * c)

#endif




static int htp__request_parse_start_(htparser * p);
static int htp__request_parse_host_(htparser * p, const char * data, size_t len);
static int htp__request_parse_port_(htparser * p, const char * data, size_t len);
Expand Down Expand Up @@ -3572,6 +3569,7 @@ evhtp_accept_socket(evhtp_t * htp, evutil_socket_t sock, int backlog)
{
int on = 1;
int res = 0;
int err = 1;

evhtp_assert(htp != NULL);

Expand Down Expand Up @@ -3617,7 +3615,7 @@ evhtp_accept_socket(evhtp_t * htp, evutil_socket_t sock, int backlog)

if (htp->server == NULL)
{
return -1;
break;
}

#ifndef EVHTP_DISABLE_SSL
Expand All @@ -3635,19 +3633,34 @@ evhtp_accept_socket(evhtp_t * htp, evutil_socket_t sock, int backlog)
}
}
#endif
err = 0;
} while (0);

if (err == 1)
{
evutil_closesocket(sock);

if (htp->server != NULL)
{
evhtp_safe_free(htp->server, evconnlistener_free);
}

return -1;
}


return res;
} /* evhtp_accept_socket */

int
evhtp_bind_sockaddr(evhtp_t * htp, struct sockaddr * sa, size_t sin_len, int backlog)
{

evutil_socket_t fd = -1;
int on = 1;
evutil_socket_t fd = -1;
int on = 1;
int error = 1;

if (htp == NULL) {
if (htp == NULL)
{
return -1;
}

Expand Down

0 comments on commit 18f7ec0

Please sign in to comment.