bug 1486137 - TRR: fix the FAMILY field in the ECS code r=valentin
authorDaniel Stenberg <daniel@haxx.se>
Mon, 03 Sep 2018 15:02:03 +0000
changeset 482859 d808a15ac4bc24da60e58b64d8357133d7637b6c
parent 482852 42469f001fcb8e9f0361e523f2498b71c78e14fd
child 482860 ca7b0659636ce6e6c8369a0d6c29d74589d10502
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersvalentin
bugs1486137
milestone63.0a1
bug 1486137 - TRR: fix the FAMILY field in the ECS code r=valentin ... since AF_INET wouldn't actually use IPv4! MozReview-Commit-ID: FCf7psawENI Differential Revision: https://phabricator.services.mozilla.com/D4749
netwerk/dns/TRR.cpp
testing/xpcshell/moz-http2/moz-http2.js
--- a/netwerk/dns/TRR.cpp
+++ b/netwerk/dns/TRR.cpp
@@ -134,18 +134,19 @@ TRR::DohEncode(nsCString &aBody, bool aD
     // The RDATA is just the ECS option setting zero subnet prefix
 
     aBody += '\0'; // upper 8 bit OPTION-CODE ECS
     aBody += 8;    // OPTION-CODE, 2 octets, for ECS is 8
 
     aBody += '\0'; // upper 8 bit OPTION-LENGTH
     aBody += 4;    // OPTION-LENGTH, 2 octets, contains the length of the payload
                    // after OPTION-LENGTH
-    aBody += '\0'; // upper 8 bit FAMILY
-    aBody += AF_INET; // FAMILY, 2 octets
+    aBody += '\0'; // upper 8 bit FAMILY. IANA Address Family Numbers registry, not the
+                   // AF_* constants!
+    aBody += 1;    // FAMILY (Ipv4), 2 octets
 
     aBody += '\0'; // SOURCE PREFIX-LENGTH      |     SCOPE PREFIX-LENGTH       |
     aBody += '\0';
 
     // ADDRESS, minimum number of octets == nothing because zero bits
   }
   return NS_OK;
 }
@@ -210,16 +211,17 @@ TRR::SendHTTPRequest()
     rv = Base64URLEncode(tmp.Length(), reinterpret_cast<const unsigned char *>(tmp.get()),
                          Base64URLEncodePaddingPolicy::Omit, body);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString uri;
     gTRRService->GetURI(uri);
     uri.Append(NS_LITERAL_CSTRING("?dns="));
     uri.Append(body);
+    LOG(("TRR::SendHTTPRequest GET dns=%s\n", body.get()));
     rv = NS_NewURI(getter_AddRefs(dnsURI), uri);
   } else {
     rv = DohEncode(body, disableECS);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString uri;
     gTRRService->GetURI(uri);
     rv = NS_NewURI(getter_AddRefs(dnsURI), uri);
--- a/testing/xpcshell/moz-http2/moz-http2.js
+++ b/testing/xpcshell/moz-http2/moz-http2.js
@@ -599,18 +599,18 @@ function handleRequest(req, res) {
     res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");
     return;
 
   }
-  // for use with test_trr.js, test8b
-  else if (u.path === "/dns-ecs?dns=AAABAAABAAAAAAABA2VjcwdleGFtcGxlA2NvbQAAAQABAAApEAAAAAAAAAgACAAEAAIAAA") {
+    // for use with test_trr.js, test8b
+  else if (u.path === "/dns-ecs?dns=AAABAAABAAAAAAABA2VjcwdleGFtcGxlA2NvbQAAAQABAAApEAAAAAAAAAgACAAEAAEAAA") {
     // the query string asks for an A entry for ecs.example.com
     // ecs.example.com has A entry 5.5.5.5
     var content= new Buffer("00000100000100010000000003656373076578616D706C6503636F6D0000010001C00C0001000100000037000405050505", "hex");
     res.setHeader('Content-Type', 'application/dns-message');
     res.setHeader('Content-Length', content.length);
     res.writeHead(200);
     res.write(content);
     res.end("");