summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongjiayang <songjiayang1@gmail.com>2019-07-09 11:34:56 +0800
committerBrad Fitzpatrick <bradfitz@golang.org>2019-11-08 22:14:43 +0000
commit4ba9e2ef068ce38cc0f710f3a9a508aa6c14b82d (patch)
tree0198ff93c13e635709f26b815760408b49f68445
parent42ef8dbebecb1aa62a4f25c93e117a1de4d9f4fc (diff)
downloadnet-4ba9e2ef068ce38cc0f710f3a9a508aa6c14b82d.tar.xz
icmp: fix ListenPacket panic
Fixes golang/go#32933 Change-Id: I837d6a54e51d91ff3260ec7e1c79412c52dff20d Reviewed-on: https://go-review.googlesource.com/c/net/+/185317 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--icmp/listen_posix.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/icmp/listen_posix.go b/icmp/listen_posix.go
index e1b1aa9..f0f1f2f 100644
--- a/icmp/listen_posix.go
+++ b/icmp/listen_posix.go
@@ -50,6 +50,9 @@ func ListenPacket(network, address string) (*PacketConn, error) {
family, proto = syscall.AF_INET6, iana.ProtocolIPv6ICMP
default:
i := last(network, ':')
+ if i < 0 {
+ i = len(network)
+ }
switch network[:i] {
case "ip4":
proto = iana.ProtocolICMP