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

Commit

Permalink
Likely defect fix for issue 42. Check connection->type to ensure that it
Browse files Browse the repository at this point in the history
is not evhtp_type_client. Also checked for c->htp to not be null in a
couple of ssl related functions.
  • Loading branch information
sftwrngnr committed Oct 26, 2017
1 parent bb0630c commit 77a0752
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2161,8 +2161,10 @@ htp__connection_writecb_(struct bufferevent * bev, void * arg)
evhtp_connection_t * c;

c = arg;

evhtp_assert(c && c->htp && c->request && c->parser && bev);
if (c->type == evhtp_type_client) /* c->htp is NULL */
evhtp_assert(c && c->request && c->parser && bev);
else
evhtp_assert(c && c->htp && c->request && c->parser && bev);

htp__hook_connection_write_(c);

Expand Down Expand Up @@ -2196,7 +2198,7 @@ htp__connection_writecb_(struct bufferevent * bev, void * arg)
* to make sure we are not over it. If we have gone over the max we set the
* keepalive bit to 0, thus closing the connection.
*/
if (c->htp->max_keepalive_requests)
if ((c->type != evhtp_type_client) && (c->htp->max_keepalive_requests))
{
if (++c->num_requests >= c->htp->max_keepalive_requests)
{
Expand Down Expand Up @@ -2680,6 +2682,8 @@ htp__ssl_add_scache_ent_(evhtp_ssl_t * ssl, evhtp_ssl_sess_t * sess)
int slen;

connection = (evhtp_connection_t *)SSL_get_app_data(ssl);
if (connection->htp == NULL)
return 0; /* We cannot get the ssl_cfg */
cfg = connection->htp->ssl_cfg;

sid = sess->session_id;
Expand All @@ -2703,6 +2707,8 @@ htp__ssl_get_scache_ent_(evhtp_ssl_t * ssl, unsigned char * sid, int sid_len, in
evhtp_ssl_sess_t * sess;

connection = (evhtp_connection_t * )SSL_get_app_data(ssl);
if (connection->htp == NULL)
return NULL; /* We have no way of getting ssl_cfg */
cfg = connection->htp->ssl_cfg;
sess = NULL;

Expand Down

0 comments on commit 77a0752

Please sign in to comment.