This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit bbc2d0236d5411ffe99b5a067406c17696d9d463 Author: Yongrong Wang <[email protected]> AuthorDate: Wed Jun 18 20:40:08 2025 +0800 netutils/iperf: accept a string CID for -c with vsock. A vsock peer may be named by a short string as well as a number. Parse the -c argument with strtoul() and, when it is not a number, copy up to sizeof(cid) bytes of the string into the CID instead of using atoi(), which silently returned 0. Signed-off-by: Yongrong Wang <[email protected]> Assisted-by: Kiro:claude-opus-4 --- netutils/iperf/iperf_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/netutils/iperf/iperf_main.c b/netutils/iperf/iperf_main.c index fdce58db3..a67d1f3fd 100644 --- a/netutils/iperf/iperf_main.c +++ b/netutils/iperf/iperf_main.c @@ -279,7 +279,15 @@ int main(int argc, FAR char *argv[]) if (cfg.flag & IPERF_FLAG_CLIENT) { - cfg.cid = atoi(iperf.client); + FAR char *endptr; + + cfg.cid = strtoul(iperf.client, &endptr, 0); + if (errno != 0 || *endptr != '\0') + { + cfg.cid = 0; + strncpy((FAR char *)&cfg.cid, iperf.client, + MIN(sizeof(cfg.cid), strlen(iperf.client))); + } } else {
