[PATCH v12 05/17] telemetry: check for path overflow

Stephen Hemminger
2026-01-26T23:25:10Z

The unix domain socket path is limited, check for overflow.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/telemetry/telemetry_legacy.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index 89ec750c09..1d73282ba8 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -102,14 +102,17 @@ register_client(const char *cmd __rte_unused, const char *params,
return -1;
}
*strchr(data, '\"') = 0;
+ addrs.sun_family = AF_UNIX;
+ if (strlcpy(addrs.sun_path, data, sizeof(addrs.sun_path)) >= sizeof(addrs.sun_path)) {
+ fprintf(stderr, "Client path too long\n");
+ return -1;
+ }

fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
if (fd < 0) {
perror("Failed to open socket");
return -1;
}
- addrs.sun_family = AF_UNIX;
- strlcpy(addrs.sun_path, data, sizeof(addrs.sun_path));

if (connect(fd, (struct sockaddr *)&addrs, sizeof(addrs)) == -1) {
perror("\nClient connection error\n");
--
2.51.0