From 9c5712a79c41ae2ce77a7479d746268ff48353a0 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 28 Apr 2025 09:10:46 +0800 Subject: [PATCH] rpc: fix off-by-one in ipc endpoint length check #26614 (#985) This change fixes a minor flaw in the check for ipc endpoint length. The max_path_size is the max path that an ipc endpoint can have, which is 208. However, that size concerns the null-terminated pathname, so we need to account for an extra null-character too. Co-authored-by: Martin Holst Swende --- rpc/ipc_unix.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index cc4bcc3b59..514e7c1592 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -31,8 +31,9 @@ import ( // ipcListen will create a Unix socket on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { - if len(endpoint) > int(max_path_size) { - log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size), + // account for null-terminator too + if len(endpoint)+1 > int(max_path_size) { + log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size-1), "endpoint", endpoint) }