Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http server: fix http_resolve path return (clang sanitizer)
  • Loading branch information
perexg committed Jul 1, 2016
1 parent 601537a commit 343c3ea
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/http.c
Expand Up @@ -100,8 +100,9 @@ int http_str2ver(const char *str)
/**
*
*/
static http_path_t *
http_resolve(http_connection_t *hc, char **remainp, char **argsp)
static int
http_resolve(http_connection_t *hc, http_path_t *_hp,
char **remainp, char **argsp)
{
http_path_t *hp;
int n = 0, cut = 0;
Expand Down Expand Up @@ -131,10 +132,14 @@ http_resolve(http_connection_t *hc, char **remainp, char **argsp)
break;
}
}
if (hp) {
*_hp = *hp;
hp = _hp;
}
pthread_mutex_unlock(hc->hc_paths_mutex);

if(hp == NULL)
return NULL;
return 0;

cut += hp->hp_len;

Expand Down Expand Up @@ -178,10 +183,10 @@ http_resolve(http_connection_t *hc, char **remainp, char **argsp)
break;

default:
return NULL;
return 0;
}

return hp;
return 1;
}


Expand Down Expand Up @@ -973,23 +978,22 @@ http_cmd_options(http_connection_t *hc)
static int
http_cmd_get(http_connection_t *hc)
{
http_path_t *hp;
http_path_t hp;
char *remain;
char *args;

if (tvhtrace_enabled())
dump_request(hc);

hp = http_resolve(hc, &remain, &args);
if(hp == NULL) {
if (!http_resolve(hc, &hp, &remain, &args)) {
http_error(hc, HTTP_STATUS_NOT_FOUND);
return 0;
}

if(args != NULL)
http_parse_args(&hc->hc_req_args, args);

return http_exec(hc, hp, remain);
return http_exec(hc, &hp, remain);
}


Expand All @@ -1004,7 +1008,7 @@ http_cmd_get(http_connection_t *hc)
static int
http_cmd_post(http_connection_t *hc, htsbuf_queue_t *spill)
{
http_path_t *hp;
http_path_t hp;
char *remain, *args, *v;

/* Set keep-alive status */
Expand Down Expand Up @@ -1047,12 +1051,11 @@ http_cmd_post(http_connection_t *hc, htsbuf_queue_t *spill)
if (tvhtrace_enabled())
dump_request(hc);

hp = http_resolve(hc, &remain, &args);
if(hp == NULL) {
if (!http_resolve(hc, &hp, &remain, &args)) {
http_error(hc, HTTP_STATUS_NOT_FOUND);
return 0;
}
return http_exec(hc, hp, remain);
return http_exec(hc, &hp, remain);
}


Expand Down

0 comments on commit 343c3ea

Please sign in to comment.