From a9397bc33e5e9cd0b96c5338b97379915898de00 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 24 Dec 2019 14:19:35 +0100 Subject: [PATCH] Padding PRR fix --- src/libdoh/src/dns.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libdoh/src/dns.rs b/src/libdoh/src/dns.rs index 368d1e6..b184681 100644 --- a/src/libdoh/src/dns.rs +++ b/src/libdoh/src/dns.rs @@ -244,9 +244,9 @@ pub fn add_edns_padding(packet: &mut Vec, block_size: usize) -> Result<(), E }; ensure!(packet_len < DNS_MAX_PACKET_SIZE, "Large packet"); let pad_len = (block_size - 1) - ((packet_len + (block_size - 1)) & (block_size - 1)); - let mut edns_padding_prr = vec![b'X'; 2 + pad_len]; - edns_padding_prr[0] = (DNS_PTYPE_PADDING >> 8) as u8; - edns_padding_prr[1] = DNS_PTYPE_PADDING as u8; + let mut edns_padding_prr = vec![b'X'; 4 + pad_len]; + BigEndian::write_u16(&mut edns_padding_prr[0..], DNS_PTYPE_PADDING); + BigEndian::write_u16(&mut edns_padding_prr[2..], pad_len as u16); let edns_padding_prr_len = edns_padding_prr.len(); let edns_rdlen_offset: usize = edns_offset + 8; ensure!(packet_len - edns_rdlen_offset >= 2, "Short packet");