Skip to content

Commit

Permalink
rpc: avoid use of cgo by hard-coding maxPathSize
Browse files Browse the repository at this point in the history
  • Loading branch information
alienc0der committed Mar 4, 2024
1 parent d92e3be commit d83e297
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 60 deletions.
33 changes: 0 additions & 33 deletions rpc/server/constants_unix.go

This file was deleted.

25 changes: 0 additions & 25 deletions rpc/server/constants_unix_nocgo.go

This file was deleted.

12 changes: 10 additions & 2 deletions rpc/server/ipc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris

package server

Expand All @@ -28,10 +29,17 @@ import (
"github.com/ethereum/go-ethereum/log"
)

const (
// On Linux, sun_path is 108 bytes in size
// see http://man7.org/linux/man-pages/man7/unix.7.html
maxPathSize = int(108)
)

// 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 > maxPathSize {
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1),
"endpoint", endpoint)
}

Expand Down

0 comments on commit d83e297

Please sign in to comment.