Skip to content

Commit 68e19dc

Browse files
committed
p2p-proxy: earlier peerID validation check
1 parent a329e4f commit 68e19dc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/corehttp/p2p_proxy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
core "github.com/ipfs/go-ipfs/core"
12+
peer "github.com/libp2p/go-libp2p-core/peer"
1213

1314
protocol "github.com/libp2p/go-libp2p-core/protocol"
1415
p2phttp "github.com/libp2p/go-libp2p-http"
@@ -60,6 +61,10 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
6061
return nil, fmt.Errorf("Invalid request path '%s'", path)
6162
}
6263

64+
if _, err := peer.Decode(split[2]); err != nil {
65+
return nil, fmt.Errorf("Invalid request path '%s'", path)
66+
}
67+
6368
if split[3] == "http" {
6469
return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil
6570
}

0 commit comments

Comments
 (0)