From 5ccdbe68ce2a58c96d0e631c01e7879aabb6953b Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 6 Feb 2023 10:30:49 +0100 Subject: [PATCH] rpc: fix off-by-one in ipc endpoint length check --- 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 249a9cf044dc..9876347708a6 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) }