From 70e6021965f363ca099702cf1b7df3c6fb01d992 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 9 Nov 2022 16:16:13 +0100 Subject: [PATCH] Remove unneeded casts --- src/dns.rs | 2 +- src/dnscrypt.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dns.rs b/src/dns.rs index 66ba682..6cf43fe 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -294,7 +294,7 @@ fn skip_name(packet: &[u8], offset: usize) -> Result { break; } label_len => label_len, - } as usize; + }; ensure!(label_len < 0x40, "Long label"); ensure!( packet_len - offset - 1 > label_len, diff --git a/src/dnscrypt.rs b/src/dnscrypt.rs index 0735b04..b477d31 100644 --- a/src/dnscrypt.rs +++ b/src/dnscrypt.rs @@ -46,7 +46,7 @@ pub const DNSCRYPT_TCP_RESPONSE_MAX_SIZE: usize = pub fn decrypt( wrapped_packet: &[u8], dnscrypt_encryption_params_set: &[Arc], -) -> Result<(SharedKey, [u8; DNSCRYPT_FULL_NONCE_SIZE as usize], Vec), Error> { +) -> Result<(SharedKey, [u8; DNSCRYPT_FULL_NONCE_SIZE], Vec), Error> { ensure!( wrapped_packet.len() >= DNSCRYPT_QUERY_MAGIC_SIZE @@ -67,7 +67,7 @@ pub fn decrypt( .find(|p| p.client_magic() == client_magic) .ok_or_else(|| anyhow!("Client magic not found"))?; - let mut nonce = [0u8; DNSCRYPT_FULL_NONCE_SIZE as usize]; + let mut nonce = [0u8; DNSCRYPT_FULL_NONCE_SIZE]; nonce[..DNSCRYPT_QUERY_NONCE_SIZE].copy_from_slice(client_nonce); let cached_shared_key = { @@ -106,7 +106,7 @@ pub fn decrypt( pub fn encrypt( packet: Vec, shared_key: &SharedKey, - nonce: &[u8; DNSCRYPT_FULL_NONCE_SIZE as usize], + nonce: &[u8; DNSCRYPT_FULL_NONCE_SIZE], max_packet_size: usize, ) -> Result, Error> { let mut wrapped_packet = Vec::with_capacity(DNS_MAX_PACKET_SIZE);