ソースを参照

Fix crash when getting unknown RRs in req.Extra

@40000000512e7adb26a22cc4 panic: interface conversion: dns.RR is *dns.RFC3597, not *dns.OPT
@40000000512e7adb26a2387c
@40000000512e7adb26a23c64 goroutine 8248 [running]:
@40000000512e7adb26a27ae4 main.serve(0x189b4900, 0x1931c690, 0x194c2280, 0x18ca8420, 0x18a4efd4, ...)
@40000000512e7adb26a2c904       /home/ask/go/src/github.com/abh/geodns/serve.go:41 +0x384
@40000000512e7adb26a30784 main._func_005(0x18b09dc8, 0x809f088, 0x189b4900, 0x1931c690, 0x194c2280, ...)
@40000000512e7adb26a3980c       /home/ask/go/src/github.com/abh/geodns/serve.go:167 +0x3e
@40000000512e7adb26a3bb34 github.com/miekg/dns.HandlerFunc.ServeDNS(0x18a4efc0, 0x189b4900, 0x1931c690, 0x194c2280, 0x189b3020, ...)
Ask Bjørn Hansen 12 年 前
コミット
636ad56540
3 ファイル変更19 行追加11 行削除
  1. 4 0
      CHANGES.md
  2. 1 1
      geodns.go
  3. 14 10
      serve.go

+ 4 - 0
CHANGES.md

@@ -1,5 +1,9 @@
 # GeoDNS Changelog
 
+## 2.2.2, February 2013
+
+* Fix crash when getting unknown RRs in Extra request section
+
 ## 2.2.1, February 2013
 
 * Beta EDNS-SUBNET support.

+ 1 - 1
geodns.go

@@ -12,7 +12,7 @@ import (
 	"time"
 )
 
-var VERSION string = "2.2.1"
+var VERSION string = "2.2.2"
 var gitVersion string
 var serverId string
 

+ 14 - 10
serve.go

@@ -38,16 +38,20 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
 	var opt_rr *dns.OPT
 
 	for _, extra := range req.Extra {
-		for _, o := range extra.(*dns.OPT).Option {
-			opt_rr = extra.(*dns.OPT)
-			switch e := o.(type) {
-			case *dns.EDNS0_NSID:
-				// do stuff with e.Nsid
-			case *dns.EDNS0_SUBNET:
-				logPrintln("Got edns", e.Address, e.Family, e.SourceNetmask, e.SourceScope)
-				if e.Address != nil {
-					edns = e
-					ip = e.Address.String()
+
+		switch extra.(type) {
+		case *dns.OPT:
+			for _, o := range extra.(*dns.OPT).Option {
+				opt_rr = extra.(*dns.OPT)
+				switch e := o.(type) {
+				case *dns.EDNS0_NSID:
+					// do stuff with e.Nsid
+				case *dns.EDNS0_SUBNET:
+					logPrintln("Got edns", e.Address, e.Family, e.SourceNetmask, e.SourceScope)
+					if e.Address != nil {
+						edns = e
+						ip = e.Address.String()
+					}
 				}
 			}
 		}