From ad2065f2aa047f5e5ea8027d245f2971fa1d7e6d Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Fri, 18 Jun 2021 13:23:13 -0400 Subject: [PATCH] Check response len do not exceed max Buffer size --- agent/dns_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/agent/dns_test.go b/agent/dns_test.go index 26d6cf887e..cd7ed4c18a 100644 --- a/agent/dns_test.go +++ b/agent/dns_test.go @@ -6751,8 +6751,13 @@ func TestDNS_EDNS_Truncate_AgentSource(t *testing.T) { } t.Parallel() - a := NewTestAgent(t, "") + a := NewTestAgent(t, ` + dns_config { + enable_truncate = true + } + `) defer a.Shutdown() + a.DNSDisableCompression(true) testrpc.WaitForLeader(t, a.RPC, "dc1") m := MockPreparedQuery{ @@ -6778,11 +6783,12 @@ func TestDNS_EDNS_Truncate_AgentSource(t *testing.T) { m := new(dns.Msg) m.SetQuestion("foo.query.consul.", dns.TypeSRV) m.SetEdns0(2048, true) + m.Compress = false c := new(dns.Client) r, _, err := c.Exchange(m, a.DNSAddr()) require.NoError(t, err) - require.Len(t, r.Answer, 53) + require.True(t, r.Len() < 2048) } }