Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
df4b22fc
Commit
df4b22fc
authored
Feb 16, 2011
by
Olivier Antoine
Committed by
Russ Cox
Feb 16, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: reject invalid net:proto network names
R=rsc CC=golang-dev
https://golang.org/cl/4129042
parent
acad4e0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
23 deletions
+19
-23
src/pkg/net/dial.go
src/pkg/net/dial.go
+17
-11
src/pkg/net/iprawsock.go
src/pkg/net/iprawsock.go
+2
-2
src/pkg/net/parse.go
src/pkg/net/parse.go
+0
-10
No files found.
src/pkg/net/dial.go
View file @
df4b22fc
...
...
@@ -24,7 +24,7 @@ import "os"
// Dial("tcp", "127.0.0.1:123", "127.0.0.1:88")
//
func
Dial
(
net
,
laddr
,
raddr
string
)
(
c
Conn
,
err
os
.
Error
)
{
switch
prefixBefore
(
net
,
':'
)
{
switch
net
{
case
"tcp"
,
"tcp4"
,
"tcp6"
:
var
la
,
ra
*
TCPAddr
if
laddr
!=
""
{
...
...
@@ -137,7 +137,7 @@ func Listen(net, laddr string) (l Listener, err os.Error) {
// The network string net must be a packet-oriented network:
// "udp", "udp4", "udp6", or "unixgram".
func
ListenPacket
(
net
,
laddr
string
)
(
c
PacketConn
,
err
os
.
Error
)
{
switch
prefixBefore
(
net
,
':'
)
{
switch
net
{
case
"udp"
,
"udp4"
,
"udp6"
:
var
la
*
UDPAddr
if
laddr
!=
""
{
...
...
@@ -162,18 +162,24 @@ func ListenPacket(net, laddr string) (c PacketConn, err os.Error) {
return
nil
,
err
}
return
c
,
nil
case
"ip"
,
"ip4"
,
"ip6"
:
var
la
*
IPAddr
if
laddr
!=
""
{
if
la
,
err
=
ResolveIPAddr
(
laddr
);
err
!=
nil
{
}
if
i
:=
last
(
net
,
':'
);
i
>
0
{
switch
net
[
0
:
i
]
{
case
"ip"
,
"ip4"
,
"ip6"
:
var
la
*
IPAddr
if
laddr
!=
""
{
if
la
,
err
=
ResolveIPAddr
(
laddr
);
err
!=
nil
{
return
nil
,
err
}
}
c
,
err
:=
ListenIP
(
net
,
la
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
,
nil
}
c
,
err
:=
ListenIP
(
net
,
la
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
,
nil
}
return
nil
,
UnknownNetworkError
(
net
)
}
src/pkg/net/iprawsock.go
View file @
df4b22fc
...
...
@@ -311,7 +311,7 @@ func DialIP(netProto string, laddr, raddr *IPAddr) (c *IPConn, err os.Error) {
if
err
!=
nil
{
return
}
switch
prefixBefore
(
net
,
':'
)
{
switch
net
{
case
"ip"
,
"ip4"
,
"ip6"
:
default
:
return
nil
,
UnknownNetworkError
(
net
)
...
...
@@ -335,7 +335,7 @@ func ListenIP(netProto string, laddr *IPAddr) (c *IPConn, err os.Error) {
if
err
!=
nil
{
return
}
switch
prefixBefore
(
net
,
':'
)
{
switch
net
{
case
"ip"
,
"ip4"
,
"ip6"
:
default
:
return
nil
,
UnknownNetworkError
(
net
)
...
...
src/pkg/net/parse.go
View file @
df4b22fc
...
...
@@ -192,16 +192,6 @@ func count(s string, b byte) int {
return
n
}
// Returns the prefix of s up to but not including the character c
func
prefixBefore
(
s
string
,
c
byte
)
string
{
for
i
,
v
:=
range
s
{
if
v
==
int
(
c
)
{
return
s
[
0
:
i
]
}
}
return
s
}
// Index of rightmost occurrence of b in s.
func
last
(
s
string
,
b
byte
)
int
{
i
:=
len
(
s
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment