Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,7 @@ JSON_read(int fd, int max_size)
char *str;
cJSON *json = NULL;
int rc;
char msg_buf[WARN_STR_LEN * 2];

/*
* Read a four-byte integer, which is the length of the JSON to follow.
Expand Down Expand Up @@ -2788,19 +2789,27 @@ JSON_read(int fd, int max_size)
json = cJSON_Parse(str);
}
else {
warning("JSON size of data read does not correspond to offered length");
snprintf(msg_buf, sizeof(msg_buf), "JSON size of data read does not correspond to offered length - expected %d bytes but received %d; errno=%d", hsize, rc, errno);
warning(msg_buf);
}
}
else {
snprintf(msg_buf, sizeof(msg_buf), "JSON data read failed; errno=%d", errno);
warning(msg_buf);
}
free(str);
}
}
}
else {
warning("JSON data length overflow");
snprintf(msg_buf, sizeof(msg_buf), "JSON data length overflow - %d bytes JSON size is not allowed", hsize);
warning(msg_buf);
}
}
else {
warning("Failed to read JSON data size");
snprintf(msg_buf, sizeof(msg_buf), "Failed to read JSON data size - read returned %d; errno=%d", rc, errno);
warning(msg_buf);
}
return json;
}
Expand Down