Skip to content

Commit

Permalink
rpc: fix off-by-one in ipc endpoint length check (ethereum#26614)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
holiman authored and shekhirin committed Jun 6, 2023
1 parent f35113c commit 5fe8706
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rpc/ipc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 5fe8706

Please sign in to comment.