Skip to content

Commit

Permalink
Fix for #1776 - do not limit JSON size for --get-server-output
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Sep 27, 2024
1 parent dab301f commit 36fff3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static int diskfile_send(struct iperf_stream *sp);
static int diskfile_recv(struct iperf_stream *sp);
static int JSON_write(int fd, cJSON *json);
static void print_interval_results(struct iperf_test *test, struct iperf_stream *sp, cJSON *json_interval_streams);
static cJSON *JSON_read(int fd);
static cJSON *JSON_read(int fd, int max_size);
static int JSONStream_Output(struct iperf_test *test, const char* event_name, cJSON* obj);


Expand Down Expand Up @@ -2367,7 +2367,7 @@ get_parameters(struct iperf_test *test)
cJSON *j;
cJSON *j_p;

j = JSON_read(test->ctrl_sck);
j = JSON_read(test->ctrl_sck, MAX_PARAMS_JSON_STRING);
if (j == NULL) {
i_errno = IERECVPARAMS;
r = -1;
Expand Down Expand Up @@ -2598,7 +2598,7 @@ get_results(struct iperf_test *test)
int retransmits;
struct iperf_stream *sp;

j = JSON_read(test->ctrl_sck);
j = JSON_read(test->ctrl_sck, 0);
if (j == NULL) {
i_errno = IERECVRESULTS;
r = -1;
Expand Down Expand Up @@ -2786,7 +2786,7 @@ JSON_write(int fd, cJSON *json)
/*************************************************************/

static cJSON *
JSON_read(int fd)
JSON_read(int fd, int max_size)
{
uint32_t hsize, nsize;
size_t strsize;
Expand All @@ -2802,7 +2802,7 @@ JSON_read(int fd)
rc = Nread(fd, (char*) &nsize, sizeof(nsize), Ptcp);
if (rc == sizeof(nsize)) {
hsize = ntohl(nsize);
if (hsize > 0 && hsize <= MAX_PARAMS_JSON_STRING) {
if (hsize > 0 && (max_size == 0 || hsize <= max_size)) {
/* Allocate a buffer to hold the JSON */
strsize = hsize + 1; /* +1 for trailing NULL */
if (strsize) {
Expand Down

0 comments on commit 36fff3c

Please sign in to comment.