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

Commit 2bf0e67

Browse files
committed
fix(http): Fix NULL request error under root path
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
1 parent 83ba4b7 commit 2bf0e67

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

connectivity/http/http.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ static int ta_http_process_request(ta_http_t *const http, char const *const url,
295295
} else if (ta_http_url_matcher(url, "/mam[/]?") == SC_OK) {
296296
if (payload != NULL) {
297297
return process_mam_send_msg_request(http, payload, out);
298-
} else {
299-
return process_method_not_allowed_request(out);
300298
}
299+
return process_method_not_allowed_request(out);
300+
301301
} else if (ta_http_url_matcher(url, "/transaction/[A-Z9]{81}[/]?") == SC_OK) {
302302
return process_find_txn_obj_single_request(http, url, out);
303303
} else if (ta_http_url_matcher(url, "/transaction/object[/]?") == SC_OK) {
304304
if (payload != NULL) {
305305
return process_find_txn_obj_request(http, payload, out);
306-
} else {
307-
return process_method_not_allowed_request(out);
308306
}
307+
return process_method_not_allowed_request(out);
308+
309309
} else if (ta_http_url_matcher(url, "/tips/pair[/]?") == SC_OK) {
310310
return process_get_tips_pair_request(http, out);
311311
} else if (ta_http_url_matcher(url, "/tips[/]?") == SC_OK) {
@@ -329,20 +329,23 @@ static int ta_http_process_request(ta_http_t *const http, char const *const url,
329329
else if (ta_http_url_matcher(url, "/transaction[/]?") == SC_OK) {
330330
if (payload != NULL) {
331331
return process_send_transfer_request(http, payload, out);
332-
} else {
333-
return process_method_not_allowed_request(out);
334332
}
333+
return process_method_not_allowed_request(out);
334+
335335
} else if (ta_http_url_matcher(url, "/tryte[/]?") == SC_OK) {
336336
if (payload != NULL) {
337337
return process_send_trytes_request(http, payload, out);
338-
} else {
339-
return process_method_not_allowed_request(out);
340338
}
339+
return process_method_not_allowed_request(out);
340+
341341
} else if (ta_http_url_matcher(url, "/info[/]?") == SC_OK) {
342342
return process_get_ta_info_request(http, out);
343343
} else if (ta_http_url_matcher(url, "/") == SC_OK) {
344-
// POST request
345-
return process_proxy_api_request(http, payload, out);
344+
if (payload != NULL) {
345+
return process_proxy_api_request(http, payload, out);
346+
}
347+
return process_method_not_allowed_request(out);
348+
346349
} else {
347350
ta_log_error("SC_HTTP_URL_NOT_MATCH : %s\n", url);
348351
return process_invalid_path_request(out);

0 commit comments

Comments
 (0)