Skip to content

Instantly share code, notes, and snippets.

@asergeyev
Last active August 29, 2015 14:05
Show Gist options
  • Save asergeyev/16db89fc6af9654422be to your computer and use it in GitHub Desktop.
Save asergeyev/16db89fc6af9654422be to your computer and use it in GitHub Desktop.
Diff for NSEC and NSEC3 and DNSSEC algorithms to be mixcase
diff --git a/zscan.go b/zscan.go
index e051d8e..ed0114f 100644
@@ -671,9 +671,11 @@ func zlexer(s *scan, c chan lex) {
if stri != 0 {
l.value = _STRING
l.token = string(str[:stri])
+ l.tokenUpper = strings.ToUpper(l.token)
+
l.length = stri
if !rrtype {
- if t, ok := StringToType[strings.ToUpper(l.token)]; ok {
+ if t, ok := StringToType[l.tokenUpper]; ok {
l.value = _RRTYPE
l.torc = t
rrtype = true
diff --git a/zscan_rr.go b/zscan_rr.go
index 42f488f..813acc9 100644
--- a/zscan_rr.go
+++ b/zscan_rr.go
@@ -6,6 +6,7 @@ package dns
import (
"encoding/base64"
"net"
"strconv"
"strings"
@@ -1147,7 +1148,7 @@ func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
l := <-c
if t, ok := StringToType[l.tokenUpper]; !ok {
if strings.HasPrefix(l.tokenUpper, "TYPE") {
- if t, ok = typeToInt(l.token); !ok {
+ if t, ok = typeToInt(l.tokenUpper); !ok {
return nil, &ParseError{f, "bad RRSIG Typecovered", l}, ""
} else {
rr.TypeCovered = t
@@ -1261,8 +1262,9 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
case _BLANK:
// Ok
case _STRING:
- if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
- if k, ok = typeToInt(l.token); !ok {
+ if k, ok = StringToType[l.tokenUpper]; !ok {
+ if k, ok = typeToInt(l.tokenUpper); !ok {
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, ""
}
}
@@ -1323,8 +1325,8 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
case _BLANK:
// Ok
case _STRING:
- if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
- if k, ok = typeToInt(l.token); !ok {
+ if k, ok = StringToType[l.tokenUpper]; !ok {
+ if k, ok = typeToInt(l.tokenUpper); !ok {
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, ""
}
}
@@ -1580,7 +1582,7 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
<-c // _BLANK
l = <-c
if i, e := strconv.Atoi(l.token); e != nil {
- if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
+ if i, ok := StringToAlgorithm[l.tokenUpper]; !ok {
return nil, &ParseError{f, "bad DS Algorithm", l}, ""
} else {
rr.Algorithm = i
@@ -1681,7 +1683,7 @@ func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
<-c // _BLANK
l = <-c
if i, e := strconv.Atoi(l.token); e != nil {
- if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
+ if i, ok := StringToAlgorithm[l.tokenUpper]; !ok {
return nil, &ParseError{f, "bad CDS Algorithm", l}, ""
} else {
rr.Algorithm = i
@@ -1716,7 +1718,7 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
<-c // _BLANK
l = <-c
if i, e := strconv.Atoi(l.token); e != nil {
- if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
+ if i, ok := StringToAlgorithm[l.tokenUpper]; !ok {
return nil, &ParseError{f, "bad DLV Algorithm", l}, ""
} else {
rr.Algorithm = i
@@ -1751,7 +1753,7 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
<-c // _BLANK
l = <-c
if i, e := strconv.Atoi(l.token); e != nil {
- if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
+ if i, ok := StringToAlgorithm[l.tokenUpper]; !ok {
return nil, &ParseError{f, "bad TA Algorithm", l}, ""
} else {
rr.Algorithm = i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment