Skip to content

Commit f23689e

Browse files
committed
feat(nom5): Use MAX_SHARED_RELAYS
1 parent 70f1ffe commit f23689e

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/toxcore/dht/packet/crypto_data.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ impl ToBytes for CryptoDataPayload {
148148
#[cfg(test)]
149149
mod tests {
150150
use super::*;
151-
use nom::{Err,
152-
error::ErrorKind
153-
};
151+
use nom::{Err, error::ErrorKind};
154152

155153
encode_decode_test!(
156154
crypto_data_encode_decode,

src/toxcore/friend_connection/packet/share_relays.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl FromBytes for ShareRelays {
3232
named!(from_bytes<ShareRelays>, do_parse!(
3333
tag!(&[PACKET_ID_SHARE_RELAYS][..]) >>
3434
relays: many0!(PackedNode::from_tcp_bytes) >>
35-
verify!(value!(relays.len()), |len| *len <= 3) >>
35+
verify!(value!(relays.len()), |len| *len <= MAX_SHARED_RELAYS) >>
3636
(ShareRelays {
3737
relays,
3838
})

src/toxcore/onion/packet/onion_request_2.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ impl FromBytes for OnionRequest2 {
4242
tag!(&[0x82][..]) >>
4343
nonce: call!(Nonce::from_bytes) >>
4444
temporary_pk: call!(PublicKey::from_bytes) >>
45-
rest_len: rest_len >>
46-
payload: map_opt!(cond!(
47-
rest_len >= ONION_RETURN_2_SIZE,
48-
take!(rest_len - ONION_RETURN_2_SIZE)
49-
), |payload| payload) >>
45+
rest_len: verify!(rest_len, |rest_len| *rest_len >= ONION_RETURN_2_SIZE) >>
46+
payload: take!(rest_len - ONION_RETURN_2_SIZE) >>
5047
onion_return: call!(OnionReturn::from_bytes) >>
5148
(OnionRequest2 {
5249
nonce,

0 commit comments

Comments
 (0)