Skip to content

Do not modify --bind and --client arguments inplace - #1960

Merged
bmah888 merged 1 commit into
esnet:masterfrom
klemensn:bind-argv
Jan 9, 2026
Merged

Do not modify --bind and --client arguments inplace#1960
bmah888 merged 1 commit into
esnet:masterfrom
klemensn:bind-argv

Conversation

@klemensn

Copy link
Copy Markdown
Contributor

Do as iperf_parse_hostname()'s comment says already: pass a copy of
getopt(3)'s optarg aka. to avoid strtok(3) scribbling over argv[].

Otherwise arguments like "fe80::1%vport0" appear as "fe80::1" in the
process list and cause exact matching of process name and arguments
(against what was used) to fail.

OpenBSD's net/iperf3 package ships a rc.subr(8) script and the service
framework uses pgrep(1) to check for running processes, where this
bug causes a mismatch due to the scope identifier being stripped:

	$ rcctl get iperf3 flags
	-6 --bind fe80::1%vport0
	$ rcctl check iperf3
	iperf3(failed)
	$ pgrep -fl iperf3
	33091 /usr/local/bin/iperf3 -s -D -6 -B fe80::1

Pass a copy to avoid modification, thus fixing rcctl(8) reporting:

	$ rcctl check iperf3
	iperf3(ok)
	$ pgrep -fl iperf3
	98863 /usr/local/bin/iperf3 -s -D -6 -B fe80::1%vport0

@bmah888

bmah888 commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Thanks for the pull request! I see and understand the problem you're trying to fix, iperf3 shouldn't go mucking around with argv[] like that. We'll take a look.

@klemensn

klemensn commented Jan 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the pull request! I see and understand the problem you're trying to fix, iperf3 shouldn't go mucking around with argv[] like that. We'll take a look.

For archives, this has since been applied to OpenBSD's iperf3 package via openbsd/ports@bd56c81.

@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.

Thanks again for the PR! I've verified that it seems to fix the problem you originally reported.

The only feedback I have deals with freeing the duplicated string under certain error handling paths (I put two comments on the PR indicate the approximate places). What do you think?

Comment thread src/iperf_api.c
Comment thread src/iperf_api.c
@bmah888 bmah888 self-assigned this Jan 8, 2026
Do as iperf_parse_hostname()'s comment says already:  pass a copy of
getopt(3)'s `optarg` aka. to avoid strtok(3) scribbling over `argv[]`.

Otherwise arguments like "fe80::1%vport0" appear as "fe80::1" in the
process list and cause exact matching of process name and arguments
(against what was used) to fail.

OpenBSD's net/iperf3 package ships a rc.subr(8) script and the service
framework uses pgrep(1) to check for running processes, where this
bug causes a mismatch due to the scope identifier being stripped:

```
	$ rcctl get iperf3 flags
	-6 --bind fe80::1%vport0
	$ rcctl check iperf3
	iperf3(failed)
	$ pgrep -fl iperf3
	33091 /usr/local/bin/iperf3 -s -D -6 -B fe80::1
```

Pass a copy to avoid modification, thus fixing rcctl(8) reporting:
```
	$ rcctl check iperf3
	iperf3(ok)
	$ pgrep -fl iperf3
	98863 /usr/local/bin/iperf3 -s -D -6 -B fe80::1%vport0
```

@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.

Thanks for the revision! Approved, and will merge this shortly.

@bmah888
bmah888 merged commit 0ae94b6 into esnet:master Jan 9, 2026
7 checks passed
@klemensn
klemensn deleted the bind-argv branch January 21, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants