Fixed SSHFP parsing when multiple lines used for text representation.
This commit is contained in:
parent
d00c3f21d4
commit
d2bed60478
|
@ -548,6 +548,9 @@ a.example.com. IN A 127.0.0.1
|
||||||
8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG
|
8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG
|
||||||
$ORIGIN a.example.com.
|
$ORIGIN a.example.com.
|
||||||
test IN A 127.0.0.1
|
test IN A 127.0.0.1
|
||||||
|
IN SSHFP 1 2 (
|
||||||
|
BC6533CDC95A79078A39A56EA7635984ED655318ADA9
|
||||||
|
B6159E30723665DA95BB )
|
||||||
$ORIGIN b.example.com.
|
$ORIGIN b.example.com.
|
||||||
test IN CNAME test.a.example.com.
|
test IN CNAME test.a.example.com.
|
||||||
`
|
`
|
||||||
|
@ -1397,10 +1400,6 @@ func TestParseTLSA(t *testing.T) {
|
||||||
t.Error("failed to parse RR: ", err)
|
t.Error("failed to parse RR: ", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if rr == nil {
|
|
||||||
t.Errorf("TLSA RR `%s` not parsed!", o)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if rr.String() != o {
|
if rr.String() != o {
|
||||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", o, o, rr.String())
|
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", o, o, rr.String())
|
||||||
} else {
|
} else {
|
||||||
|
@ -1408,3 +1407,25 @@ func TestParseTLSA(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseSSHFP(t *testing.T) {
|
||||||
|
lt := []string{
|
||||||
|
"test.example.org.\t300\tSSHFP\t1 2 (\n" +
|
||||||
|
"\t\t\t\t\tBC6533CDC95A79078A39A56EA7635984ED655318ADA9\n" +
|
||||||
|
"\t\t\t\t\tB6159E30723665DA95BB )",
|
||||||
|
"test.example.org.\t300\tSSHFP\t1 2 ( BC6533CDC 95A79078A39A56EA7635984ED655318AD A9B6159E3072366 5DA95BB )",
|
||||||
|
}
|
||||||
|
result := "test.example.org.\t300\tIN\tSSHFP\t1 2 BC6533CDC95A79078A39A56EA7635984ED655318ADA9B6159E30723665DA95BB"
|
||||||
|
for _, o := range lt {
|
||||||
|
rr, err := NewRR(o)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("failed to parse RR: ", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if rr.String() != result {
|
||||||
|
t.Errorf("`%s' should be equal to\n\n`%s', but is \n`%s'", o, result, rr.String())
|
||||||
|
} else {
|
||||||
|
t.Logf("RR is OK: `%s'", rr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
17
zscan_rr.go
17
zscan_rr.go
|
@ -1485,8 +1485,11 @@ func setSSHFP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
}
|
}
|
||||||
rr.Type = uint8(i)
|
rr.Type = uint8(i)
|
||||||
<-c // zBlank
|
<-c // zBlank
|
||||||
l = <-c
|
s, e1, c1 := endingToString(c, "bad SSHFP Fingerprint", f)
|
||||||
rr.FingerPrint = l.token
|
if e1 != nil {
|
||||||
|
return nil, e1, c1
|
||||||
|
}
|
||||||
|
rr.FingerPrint = s
|
||||||
return rr, nil, ""
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,14 +1613,8 @@ func setNSAP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
if l.length == 0 {
|
if l.length == 0 {
|
||||||
return rr, nil, l.comment
|
return rr, nil, l.comment
|
||||||
}
|
}
|
||||||
i, e := strconv.Atoi(l.token)
|
|
||||||
if e != nil {
|
|
||||||
return nil, &ParseError{f, "bad NSAP Length", l}, ""
|
|
||||||
}
|
|
||||||
rr.Length = uint8(i)
|
|
||||||
<-c // zBlank
|
|
||||||
s, e1, c1 := endingToString(c, "bad NSAP Nsap", f)
|
s, e1, c1 := endingToString(c, "bad NSAP Nsap", f)
|
||||||
if e != nil {
|
if e1 != nil {
|
||||||
return nil, e1, c1
|
return nil, e1, c1
|
||||||
}
|
}
|
||||||
rr.Nsap = s
|
rr.Nsap = s
|
||||||
|
@ -2202,7 +2199,7 @@ var typeToparserFunc = map[uint16]parserFunc{
|
||||||
TypeSOA: parserFunc{setSOA, false},
|
TypeSOA: parserFunc{setSOA, false},
|
||||||
TypeSPF: parserFunc{setSPF, true},
|
TypeSPF: parserFunc{setSPF, true},
|
||||||
TypeSRV: parserFunc{setSRV, false},
|
TypeSRV: parserFunc{setSRV, false},
|
||||||
TypeSSHFP: parserFunc{setSSHFP, false},
|
TypeSSHFP: parserFunc{setSSHFP, true},
|
||||||
TypeTALINK: parserFunc{setTALINK, false},
|
TypeTALINK: parserFunc{setTALINK, false},
|
||||||
TypeTA: parserFunc{setTA, true},
|
TypeTA: parserFunc{setTA, true},
|
||||||
TypeTLSA: parserFunc{setTLSA, true},
|
TypeTLSA: parserFunc{setTLSA, true},
|
||||||
|
|
Loading…
Reference in New Issue