Commit 7a0dc7cc authored by valenting's avatar valenting
Browse files

Bug 1635566 - TRR: Perform a case-insensitive match for the host name r=necko-reviewers,dragana

This is according to RFC 4343 : Domain Name System (DNS) Case Insensitivity Clarification

Differential Revision: https://phabricator.services.mozilla.com/D75081
parent 681c9b47
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -873,10 +873,14 @@ nsresult TRR::DohDecode(nsCString& aHost) {
      return NS_ERROR_ILLEGAL_VALUE;
    }

    // We check if the qname matches the host or the FQDN version of the host
    if (qname.Equals(aHost) ||
        (aHost.Length() == qname.Length() + 1 && aHost.Last() == '.' &&
         StringBeginsWith(aHost, qname))) {
    // We check if the qname is a case-insensitive match for the host or the
    // FQDN version of the host
    bool responseMatchesQuestion =
        (qname.Length() == aHost.Length() ||
         (aHost.Length() == qname.Length() + 1 && aHost.Last() == '.')) &&
        qname.Compare(aHost.BeginReading(), true, qname.Length()) == 0;

    if (responseMatchesQuestion) {
      // RDATA
      // - A (TYPE 1):  4 bytes
      // - AAAA (TYPE 28): 16 bytes
+12 −0
Original line number Diff line number Diff line
@@ -125,5 +125,17 @@ add_task(async function test_trr_casing() {
  ]);
  await new TRRDNSListener("a.test.com", "8.8.8.8");

  await trrServer.registerDoHAnswers("CAPITAL.COM", "A", [
    {
      name: "capital.com",
      ttl: 55,
      type: "A",
      flush: false,
      data: "2.2.2.2",
    },
  ]);
  await new TRRDNSListener("CAPITAL.COM", "2.2.2.2");
  await new TRRDNSListener("CAPITAL.COM.", "2.2.2.2");

  await trrServer.stop();
});