telemetry: fix potential connection issue
Checks
Commit Message
For calling memcpy when the source and destination addresses are the same,
there is a small probability that there will be a copy error issue in some
environments, resulting in a failure to connect.
This patch uses memmove instead of memcpy to avoid this issue.
Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
Cc: stable@dpdk.org
Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
lib/telemetry/telemetry_legacy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> -----Original Message-----
> From: Zhichao Zeng <zhichaox.zeng@intel.com>
> Sent: Friday, June 21, 2024 10:41 AM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Zeng, ZhichaoX <zhichaox.zeng@intel.com>;
> Richardson, Bruce <bruce.richardson@intel.com>; Wiles, Keith
> <keith.wiles@intel.com>; Ciara Power <ciara.power@intel.com>
> Subject: [PATCH] telemetry: fix potential connection issue
>
> For calling memcpy when the source and destination addresses are the same,
> there is a small probability that there will be a copy error issue in some
> environments, resulting in a failure to connect.
>
> This patch uses memmove instead of memcpy to avoid this issue.
>
> Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
> Cc: stable@dpdk.org
>
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> ---
Tested-by: Song Jiale <songx.jiale@intel.com>
26/06/2024 04:13, Jiale, SongX:
> From: Zhichao Zeng <zhichaox.zeng@intel.com>
> >
> > For calling memcpy when the source and destination addresses are the same,
> > there is a small probability that there will be a copy error issue in some
> > environments, resulting in a failure to connect.
> >
> > This patch uses memmove instead of memcpy to avoid this issue.
> >
> > Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> > ---
> Tested-by: Song Jiale <songx.jiale@intel.com>
It would be cleaner to do a proper parsing before doing any copy (strlcpy, memcpy/memmove).
dirty code dirty fixed for now
Applied
@@ -94,7 +94,7 @@ register_client(const char *cmd __rte_unused, const char *params,
}
#ifndef RTE_EXEC_ENV_WINDOWS
strlcpy(data, strchr(params, ':'), sizeof(data));
- memcpy(data, &data[strlen(":\"")], strlen(data));
+ memmove(data, &data[strlen(":\"")], strlen(data));
if (!strchr(data, '\"')) {
fprintf(stderr, "Invalid client data\n");
return -1;