Skip to content

Add JSON value checks for get_parameters.#2039

Merged
swlars merged 3 commits into
masterfrom
check_json_get_parameters
May 20, 2026
Merged

Add JSON value checks for get_parameters.#2039
swlars merged 3 commits into
masterfrom
check_json_get_parameters

Conversation

@swlars

@swlars swlars commented May 20, 2026

Copy link
Copy Markdown
Contributor

Add more checks and more specific error values to JSON int values in get_parameters.

Special thanks to Dirk Müller for directing our attention to this.

PLEASE NOTE the following text from the iperf3 license. Submitting a
pull request to the iperf3 repository constitutes "[making]
Enhancements available...publicly":

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National
Laboratory, without imposing a separate written license agreement for such
Enhancements, then you hereby grant the following license: a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare derivative
works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code form.

The complete iperf3 license is available in the LICENSE file in the
top directory of the iperf3 source tree.

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies:

  • Issues fixed (if any):
    Adds more checks and specific errors for some of the JSON int values in get_parameters.

  • Brief description of code changes (suitable for use as a commit message):

Special thanks to Dirk Müller for directing our attention to this.
@swlars swlars self-assigned this May 20, 2026
@swlars swlars requested a review from bmah888 May 20, 2026 22:18
@swlars swlars added the bug:json Bugs related to JSON output label May 20, 2026

@bmah888 bmah888 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approved!

@swlars swlars merged commit 494dd37 into master May 20, 2026
7 checks passed
Comment thread src/iperf_api.c
case 'P':
test->num_streams = atoi(optarg);
if (test->num_streams > MAX_STREAMS) {
if (test->num_streams < 0 || test->num_streams > MAX_STREAMS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that num_streams should be at least 1, as 0 streams is probably meaningless. This is also the default value and in addition iperf_print_results() divides by the value: avg_jitter /= test->num_streams;. (I just happened to see this as the change created a conflict with an old PR I submitted.)

Comment thread src/iperf_api.c
if ((j_p = iperf_cJSON_GetObjectItemType(j, "parallel", cJSON_Number)) != NULL)
test->num_streams = j_p->valueint;
if ((j_p = iperf_cJSON_GetObjectItemType(j, "parallel", cJSON_Number)) != NULL){
if (j_p->valueint < 0 || j_p->valueint > MAX_STREAMS) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the P option, num_streams should probably be at least 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug:json Bugs related to JSON output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants