Skip to content

Commit

Permalink
Veify that Params JSON size was received and is resonable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Jun 2, 2024
1 parent 8f5a87e commit 3eb15a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ struct iperf_test

#define UDP_BUFFER_EXTRA 1024

#define MAX_PARAMS_JSON_STRING 8 * 1024

/* constants for command line arg sanity checks */
#define MB (1024 * 1024)
#define MAX_TCP_BUFFER (512 * MB)
Expand Down
5 changes: 3 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2728,8 +2728,9 @@ JSON_read(int fd)
* Then read the JSON into a buffer and parse it. Return a parsed JSON
* structure, NULL if there was an error.
*/
if (Nread(fd, (char*) &nsize, sizeof(nsize), Ptcp) >= 0) {
hsize = ntohl(nsize);
rc = Nread(fd, (char*) &nsize, sizeof(nsize), Ptcp);
hsize = ntohl(nsize);
if (rc == sizeof(nsize) && hsize <= MAX_PARAMS_JSON_STRING) {
/* Allocate a buffer to hold the JSON */
strsize = hsize + 1; /* +1 for trailing NULL */
if (strsize) {
Expand Down

0 comments on commit 3eb15a4

Please sign in to comment.