Skip to content

Commit

Permalink
httpd: Do not crash on empty-body POSTs
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed Jun 3, 2019
1 parent 5e4a99e commit 69e5c8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/sliblist.c
Expand Up @@ -127,7 +127,7 @@ int slinkedl_traverse(slinkedl_list_t *list,

void *slinkedl_peek(slinkedl_list_t *list)
{
if (!list)
if (!list || !list->head)
return NULL;

return list->head->data;
Expand Down
6 changes: 4 additions & 2 deletions modules/httpd/httpd_proc.c
Expand Up @@ -414,7 +414,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection,
str_str_t *kv;
char *p;
int ret_code = MHD_HTTP_OK;
str saved_body;
str saved_body = STR_NULL;

#if ( MHD_VERSION >= 0x000092800 )
int sv_sockfd;
Expand Down Expand Up @@ -485,7 +485,9 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection,
if (cb) {
normalised_url = &url[cb->http_root->len+1];
LM_DBG("normalised_url=[%s]\n", normalised_url);
saved_body = ((str_str_t *)slinkedl_peek(pr->p_list))->val;
kv = slinkedl_peek(pr->p_list);
if (kv)
saved_body = ((str_str_t *)kv)->val;
ret_code = cb->callback(cls, (void*)connection,
normalised_url,
method, version,
Expand Down

0 comments on commit 69e5c8d

Please sign in to comment.