On Thu, Oct 30, 2025 at 05:49:15PM +0000, Klemens Nanni wrote:
> If the argument contains a '%', the code will modify argv[] in place,
> which causes rc.subr(8)'s pexp aka. pgrep(1) to mismatch and thus
> rcctl(8) to report failure despite the service running fine:
> 
>       $ 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 --bind fe80::1
> 
> 
> Funnily, the code knows that:
> 
>        * Modifies the string pointed to by spec in-place due to the use of
>                 * strtok(3). The caller should strdup(3) or otherwise copy 
> the string
>        * if an unmodified copy is needed.
>        */
>       int
>       iperf_parse_hostname(struct iperf_test *test, char *spec, char **p, 
> char **p1) {
> 
> 
> Simply pass a copy to that function to keep scope identifies in argv[]:
> 
>       $ rcctl check iperf3
>       iperf3(ok)
>       $ pgrep -fl iperf3
>       98863 /usr/local/bin/iperf3 -s -D -6 --bind fe80::1%vport0
> 
> --client works the same as --bind, so fix it as well.
> 
> Feedback? OK?

Nit that isn't just a nit: I guess this is only used at startup, but
I'd suggest to check the return value of strdup(3), just for
correctness.

-- 
jca

Reply via email to