telemetry: fix potential connection issue

Message ID 20240621024037.3412372-1-zhichaox.zeng@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series telemetry: fix potential connection issue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Zhichao Zeng June 21, 2024, 2:40 a.m. UTC
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

Jiale, SongX June 26, 2024, 2:13 a.m. UTC | #1
> -----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>
  
Thomas Monjalon July 7, 2024, 1:11 p.m. UTC | #2
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
  

Patch

diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index 4c1d1c353a..578230732c 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -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;