Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

Commit1798bb2

Browse files
committed
[release-branch.go1.3] net: Don't read beyond end of slice when parsing resolv.conf options.
««« CL 102470046 / 5207b394de96net: Don't read beyond end of slice when parsing resolv.conf options.Fixes#8252.LGTM=adgR=ruiu, josharian, adgCC=golang-codereviewshttps://golang.org/cl/102470046»»»TBR=rscCC=golang-codereviewshttps://golang.org/cl/124140043
1 parent0752bc8 commit1798bb2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎src/pkg/net/dnsconfig_unix.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
7575
fori:=1;i<len(f);i++ {
7676
s:=f[i]
7777
switch {
78-
caselen(s)>=6&&s[0:6]=="ndots:":
78+
casehasPrefix(s,"ndots:"):
7979
n,_,_:=dtoi(s,6)
8080
ifn<1 {
8181
n=1
8282
}
8383
conf.ndots=n
84-
caselen(s)>=8&&s[0:8]=="timeout:":
84+
casehasPrefix(s,"timeout:"):
8585
n,_,_:=dtoi(s,8)
8686
ifn<1 {
8787
n=1
8888
}
8989
conf.timeout=n
90-
caselen(s)>=8&&s[0:9]=="attempts:":
90+
casehasPrefix(s,"attempts:"):
9191
n,_,_:=dtoi(s,9)
9292
ifn<1 {
9393
n=1
@@ -103,3 +103,7 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
103103

104104
returnconf,nil
105105
}
106+
107+
funchasPrefix(s,prefixstring)bool {
108+
returnlen(s)>=len(prefix)&&s[:len(prefix)]==prefix
109+
}

‎src/pkg/net/testdata/resolv.conf‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
domain Home
44
nameserver 192.168.1.1
55
options ndots:5 timeout:10 attempts:3 rotate
6+
options attempts 3

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp