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

Commit 0fee66a

Browse files
authored
Merge pull request #409 from HowJMay/fix_messy_req
fix: Fix miscellaneous request payload
2 parents 0a944b4 + 01196e3 commit 0fee66a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

accelerator/http.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,14 @@ static int ta_http_handler(void *cls, struct MHD_Connection *connection, const c
360360
// While upload_data_size > 0 process upload_data
361361
if (*upload_data_size > 0) {
362362
if (http_req->request == NULL) {
363-
http_req->request = (char *)malloc(*upload_data_size);
363+
http_req->request = (char *)malloc((*upload_data_size) + 1);
364+
if (http_req->request == NULL) {
365+
ta_log_error("%s\n", "Not enough size for allocating HTTP request payload.");
366+
goto cleanup;
367+
}
368+
364369
strncpy(http_req->request, upload_data, *upload_data_size);
370+
http_req->request[*upload_data_size] = 0;
365371
} else {
366372
ret = MHD_NO;
367373
ta_log_error("%s\n", "MHD_NO");

tests/test_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include "accelerator/common_core.h"
1212
#include "iota_api_mock.hh"
1313

14-
using ::testing::_;
1514
using ::testing::AtLeast;
1615
using ::testing::ElementsAreArray;
16+
using ::testing::_;
1717

1818
APIMock APIMockObj;
1919
iota_config_t tangle;

0 commit comments

Comments
 (0)