Bug 1734165 - Test that padding in edns response doesn't effect parsing edns response r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D186795
This commit is contained in:
Manuel Bucher 2023-08-24 15:40:58 +00:00
Родитель 4cd7999022
Коммит a09532f829
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -347,6 +347,7 @@ function handleRequest(req, res) {
return null;
}
let answers = [];
if (packet.questions.length && packet.questions[0].name.endsWith(".pd")) {
// Bug 1543811: test edns padding extension. Return whether padding was
// included via the first half of the ip address (1.1 vs 2.2) and the
@ -357,6 +358,16 @@ function handleRequest(req, res) {
packet.additionals[0].type == "OPT" &&
packet.additionals[0].options.some(o => o.type === "PADDING")
) {
// add padding to the response, because the client must be able ignore it
answers.push({
name: ".",
type: "PADDING",
data: Buffer.from(
// PADDING_PADDING_PADDING
"50414444494e475f50414444494e475f50414444494e47",
"hex"
),
});
responseIP =
"1.1." +
((requestPayload.length >> 8) & 0xff) +
@ -397,7 +408,6 @@ function handleRequest(req, res) {
return responseIP;
}
let answers = [];
if (
responseIP != "none" &&
responseType(packet, responseIP) == packet.questions[0].type