dont panic on empty SRV segments (#5173)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2022-02-09 13:52:53 -05:00 committed by GitHub
parent daace98352
commit 4349b6fa63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -82,6 +82,9 @@ func parseRequest(name, zone string) (r recordRequest, err error) {
// stripUnderscore removes a prefixed underscore from s.
func stripUnderscore(s string) string {
if len(s) == 0 {
return s
}
if s[0] != '_' {
return s
}

View file

@ -23,6 +23,8 @@ func TestParseRequest(t *testing.T) {
{"svc.inter.webs.tests.", "....."},
// bare pod type
{"pod.inter.webs.tests.", "....."},
// SRV request with empty segments
{"..webs.mynamespace.svc.inter.webs.tests.", "...webs.mynamespace.svc"},
}
for i, tc := range tests {
m := new(dns.Msg)