Skip to content

Commit

Permalink
StrictNSQuery should fail on invalid qname input
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzen committed Mar 5, 2019
1 parent eb66606 commit 259094a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions goresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
ErrRrsigValidityPeriod = errors.New("invalid RRSIG validity period")
ErrUnknownDsDigestType = errors.New("unknown DS digest type")
ErrDsInvalid = errors.New("DS RR does not match DNSKEY")
ErrInvalidQuery = errors.New("invalid query input")
)

var resolver *Resolver
Expand Down
2 changes: 1 addition & 1 deletion lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (resolver *Resolver) LookupIPType(qname string, qtype uint16) (ips []net.IP
func (resolver *Resolver) StrictNSQuery(qname string, qtype uint16) (rrSet []dns.RR, err error) {

if len(qname) < 1 {
return nil, nil
return nil, ErrInvalidQuery
}

answer, err := queryRRset(qname, qtype)
Expand Down
11 changes: 11 additions & 0 deletions lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,14 @@ func TestMissingDsRR(t *testing.T) {
t.Error("should return no results")
}
}

func TestStrictNSQueryEmptyInput(t *testing.T) {
resolver := newResolver(t)
rrs, err := resolver.StrictNSQuery("", dns.TypeMX)
if err == nil {
t.Error("should return err")
}
if len(rrs) > 0 {
t.Error("shouldn't return results")
}
}

0 comments on commit 259094a

Please sign in to comment.