Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(http): Fix NULL request error under root path
Browse files Browse the repository at this point in the history
If we send GET request under root URL path, the HTTP
router would not handle it and return segmentation fault. We
need to use function `process_method_not_allowed_request()`
to block this error
  • Loading branch information
howjmay committed Jan 9, 2020
1 parent 83ba4b7 commit 2bf0e67
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions connectivity/http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,17 @@ static int ta_http_process_request(ta_http_t *const http, char const *const url,
} else if (ta_http_url_matcher(url, "/mam[/]?") == SC_OK) {
if (payload != NULL) {
return process_mam_send_msg_request(http, payload, out);
} else {
return process_method_not_allowed_request(out);
}
return process_method_not_allowed_request(out);

} else if (ta_http_url_matcher(url, "/transaction/[A-Z9]{81}[/]?") == SC_OK) {
return process_find_txn_obj_single_request(http, url, out);
} else if (ta_http_url_matcher(url, "/transaction/object[/]?") == SC_OK) {
if (payload != NULL) {
return process_find_txn_obj_request(http, payload, out);
} else {
return process_method_not_allowed_request(out);
}
return process_method_not_allowed_request(out);

} else if (ta_http_url_matcher(url, "/tips/pair[/]?") == SC_OK) {
return process_get_tips_pair_request(http, out);
} else if (ta_http_url_matcher(url, "/tips[/]?") == SC_OK) {
Expand All @@ -329,20 +329,23 @@ static int ta_http_process_request(ta_http_t *const http, char const *const url,
else if (ta_http_url_matcher(url, "/transaction[/]?") == SC_OK) {
if (payload != NULL) {
return process_send_transfer_request(http, payload, out);
} else {
return process_method_not_allowed_request(out);
}
return process_method_not_allowed_request(out);

} else if (ta_http_url_matcher(url, "/tryte[/]?") == SC_OK) {
if (payload != NULL) {
return process_send_trytes_request(http, payload, out);
} else {
return process_method_not_allowed_request(out);
}
return process_method_not_allowed_request(out);

} else if (ta_http_url_matcher(url, "/info[/]?") == SC_OK) {
return process_get_ta_info_request(http, out);
} else if (ta_http_url_matcher(url, "/") == SC_OK) {
// POST request
return process_proxy_api_request(http, payload, out);
if (payload != NULL) {
return process_proxy_api_request(http, payload, out);
}
return process_method_not_allowed_request(out);

} else {
ta_log_error("SC_HTTP_URL_NOT_MATCH : %s\n", url);
return process_invalid_path_request(out);
Expand Down

0 comments on commit 2bf0e67

Please sign in to comment.