rpc: fix off-by-one in ipc endpoint length check (#26614)

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.
This commit is contained in:
Martin Holst Swende 2023-02-06 07:25:42 -05:00 committed by GitHub
parent bd726f86b8
commit 8e92881a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -31,8 +31,9 @@ import (
// ipcListen will create a Unix socket on the given endpoint. // ipcListen will create a Unix socket on the given endpoint.
func ipcListen(endpoint string) (net.Listener, error) { func ipcListen(endpoint string) (net.Listener, error) {
if len(endpoint) > int(max_path_size) { // account for null-terminator too
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size), 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) "endpoint", endpoint)
} }