Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin/file: fix panic in miekg/dns.CompareDomainName() #3337

Merged
merged 1 commit into from Oct 1, 2019

Conversation

@UladzimirTrehubenka
Copy link
Contributor

UladzimirTrehubenka commented Oct 1, 2019

Observed with CoreDNS v1.6.4 and miekg/dns v1.1.19

panic: runtime error: index out of range [-1]
goroutine 57 [running]:
    /vendor/github.com/miekg/dns.CompareDomainName(0xc000127600, 0x1e, 0x0, 0x0, 0x20)
    /vendor/github.com/miekg/dns/labels.go:62 +0x224
    /vendor/github.com/miekg/dns.IsSubDomain(0xc000127600, 0x1e, 0x0, 0x0, 0x0)
    /vendor/github.com/miekg/dns/defaults.go:253 +0x49
    /vendor/github.com/coredns/coredns/plugin/file.(*Zone).additionalProcessing(0xc0001e4200, 0xc000120480, 0x1, 0x1, 0xc000155c00, 0x1e, 0x1, 0x0)
    /vendor/github.com/coredns/coredns/plugin/file/lookup.go:375 +0x113
    /vendor/github.com/coredns/coredns/plugin/file.(*Zone).Lookup(0xc0001e4200, 0xe88820, 0xc0002c0180, 0xc00019ab40, 0xe8f980, 0xc000141420, 0x0, 0x0, 0x0, 0xc000158db8, ...)
    /vendor/github.com/coredns/coredns/plugin/file/lookup.go:174 +0x2ae9
    /vendor/github.com/coredns/coredns/plugin/file.File.ServeDNS(0xe7dd20, 0xc0002309c0, 0xc000230810, 0xc000120490, 0x1, 0x1, 0xe88820, 0xc0002c0180, 0xe8f980, 0xc000141420, ...)
    /vendor/github.com/coredns/coredns/plugin/file/file.go:85 +0x2d1

Root of the issue: there are no check in CompareDomainName(s1, s2 string) (n int) that s1 or s2 is empty (see https://github.com/miekg/dns/blob/master/labels.go#L51).
On CoreDNS file plugin we could have empty string (see https://github.com/coredns/coredns/blob/master/plugin/file/lookup.go#L366).

cc: @miekg

@corbot corbot bot requested a review from miekg Oct 1, 2019
@corbot

This comment has been minimized.

Copy link

corbot bot commented Oct 1, 2019

Thank you for your contribution. I've just checked the OWNERS files to find a suitable reviewer. This search was successful and I've asked miekg (via plugin/file/OWNERS) for a review.
Note this is not an exclusive request. Anyone is free to provide a review of this pull request.

If you have questions or suggestions for this bot, please file an issue against the miekg/dreck repository.

The bot understands the commands that are listed here.

@UladzimirTrehubenka UladzimirTrehubenka force-pushed the UladzimirTrehubenka:dev branch from 7cd400d to 718f2f9 Oct 1, 2019
Signed-off-by: utrehubenka <utrehubenka@infoblox.com>
@UladzimirTrehubenka UladzimirTrehubenka force-pushed the UladzimirTrehubenka:dev branch from 718f2f9 to 797e6d3 Oct 1, 2019
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Oct 1, 2019

Codecov Report

Merging #3337 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3337      +/-   ##
==========================================
- Coverage   55.22%   55.19%   -0.03%     
==========================================
  Files         216      216              
  Lines       10774    10774              
==========================================
- Hits         5950     5947       -3     
- Misses       4365     4368       +3     
  Partials      459      459
Impacted Files Coverage Δ
plugin/file/lookup.go 76.04% <100%> (ø) ⬆️
plugin/forward/connect.go 81.69% <0%> (-4.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ffbee2...797e6d3. Read the comment docs.

@miekg miekg merged commit 7b69dfe into coredns:master Oct 1, 2019
4 checks passed
4 checks passed
DCO DCO
Details
ci/circleci: kubernetes-tests Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
stickler-ci No lint errors found.
@UladzimirTrehubenka UladzimirTrehubenka deleted the UladzimirTrehubenka:dev branch Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.