Skip to content

Commit 429e853

Browse files
authored
Merge pull request #42 from alienc0der/rpc-server
rpc: avoid use of cgo by hard-coding maxPathSize
2 parents d92e3be + d83e297 commit 429e853

File tree

3 files changed

+10
-60
lines changed

3 files changed

+10
-60
lines changed

rpc/server/constants_unix.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

rpc/server/constants_unix_nocgo.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

rpc/server/ipc_unix.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

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

1920
package server
2021

@@ -28,10 +29,17 @@ import (
2829
"github.com/ethereum/go-ethereum/log"
2930
)
3031

32+
const (
33+
// On Linux, sun_path is 108 bytes in size
34+
// see http://man7.org/linux/man-pages/man7/unix.7.html
35+
maxPathSize = int(108)
36+
)
37+
3138
// ipcListen will create a Unix socket on the given endpoint.
3239
func ipcListen(endpoint string) (net.Listener, error) {
33-
if len(endpoint) > int(max_path_size) {
34-
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size),
40+
// account for null-terminator too
41+
if len(endpoint)+1 > maxPathSize {
42+
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1),
3543
"endpoint", endpoint)
3644
}
3745

0 commit comments

Comments
 (0)