Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rfc7871: fix ECS addr truncation and add strict check #102

Merged
merged 1 commit into from
May 27, 2021

Conversation

xofyarg
Copy link
Contributor

@xofyarg xofyarg commented Apr 30, 2021

The code panics when the prefix length is 0(minus overflow) or at
byte boundary(shift overflow), fixed it and added more tests.

Added a strict check in parser, according to RFC, it should return
form error when there are non-zero bits beyond the prefix length.

@xofyarg
Copy link
Contributor Author

xofyarg commented Apr 30, 2021

@partim sorry about the bad commit #101. Do you think the opt constructor should enforce the address with correct bits, even before composing it into bytes?

The commit also includes some changes due to rustfmt, I can remove it if you don't prefer that.

@xofyarg xofyarg force-pushed the ecs-truncate-bits branch from 3dc6c9b to 4092d81 Compare April 30, 2021 02:45
@partim
Copy link
Member

partim commented May 12, 2021

Do you think the opt constructor should enforce the address with correct bits, even before composing it into bytes?

I think quietly changing the bits to zero is more user friendly. But doing that in the constructor rather than only when composing might be a better approach as ClientSubnet::addr will then always return the ‘proper’ address. So, enforce that the addr field always conforms with the RFC as an invariant of the type.

The commit also includes some changes due to rustfmt, I can remove it if you don't prefer that.

Nah, that’s fine.

@xofyarg xofyarg force-pushed the ecs-truncate-bits branch 3 times, most recently from f5901f7 to a04035b Compare May 14, 2021 07:39
@xofyarg
Copy link
Contributor Author

xofyarg commented May 14, 2021

I added some checks inside the constructor.

CI seems has an issue with beta toolchain. stable works fine on my side though.

@partim
Copy link
Member

partim commented May 26, 2021

Once again, sorry for the delay. Between all the holidays in May and other projects, this PR sadly slipped.

I have fixed Clippy’s warnings and disabled it for Beta in main, so if you could merge main into your branch, we should go green on the actions and then can merge the PR.

@xofyarg xofyarg force-pushed the ecs-truncate-bits branch from a04035b to 3d7232a Compare May 26, 2021 15:49
The code panics when the prefix length is 0(minus overflow) or at
byte boundary(shift overflow), fixed it and added more tests.

Added a strict check in parser, according to RFC, it should return
form error when there are non-zero bits beyond the prefix length.
@xofyarg xofyarg force-pushed the ecs-truncate-bits branch from 3d7232a to 836e453 Compare May 26, 2021 16:03
@xofyarg
Copy link
Contributor Author

xofyarg commented May 26, 2021

No worries, and glad to hear you got long vacations!

The PR has been rebased.

@partim partim merged commit 670bb43 into NLnetLabs:main May 27, 2021
partim added a commit that referenced this pull request Sep 15, 2022
Breaking Changes

* The minimum supported Rust version is now 1.56.1. (#128)
* The OctetsBuilder trait does not require AsRef<[u8]> and
  AsMut<[u8]> any more. These have been added as explicit trait bounds
  where needed. In return, Cow<[u8]> can now be used as an octets
  builder where AsMut<[u8]> is not needed. [#130].
* The Display implementation for UncertainDname now ends an absolute
  name with a dot to match the behaviour of the FromStr implementation.
  (#116)
* The salt and hash parameters of Nsec3 and Nsec3Param have been
  wrapped in newtypes. (#116)
* Functions depending on the rand crate have been moved behind a new
  random feature as rand is not available on all systems, even with
  std support. The feature is, however, part of the default features.

  In particular, this means that Header::set_random_id,
  MessageBuilder::request_axfr, and opt::rfc7830::PaddingMode::Random
  are only available if the feature is enabled. (#117 by @Jezza)
* resolv::Resolver::Query now has to be Send. This will allow the
  resolver to be used in async functions spawned onto a Tokio runtime.

  The stub resolver’s query struct is already Send, so no actual changes
  are necessary. However, because this changes the definition of the Resolver
  trait, this is a breaking change, anyway. (#125)

New

* base::header::Flag for easier working for the flags of a message
  header. (#109 by @tomaskrizek)
* base::name::OwnedLabel now implements Clone and Copy as well as
  Display and Debug. (#112)
* base::record::Record::into_owner_and_name allows decomposing a record
  into its two parts that aren’t Copy. (#114)
* Initial support for SVCB and HTTPS record types. (#115 by @xofyarg)
* Introduced Serde support for all relevant types. (#116)
* The OctetsBuilder trait is now also implemented for mutable references
  of types that are octet builders and turn into themselves when frozen
  (i.e., OctetsBuilder::Octets = Self). (#121)
* Support for [heapless::Vec<u8, N>] as an octets sequence via the new
  heapless feature. (#122 by @bugadani)
* The parameter types for SVCB record data now also implement Eq
  (#135)

Bug Fixes

* Correctly encode and decode the address in EDNS client subnet when the
  number of bits isn’t divisible by 8. (#101 and #102 by @xofyarg)
* validate:
  * Check for the correct public key size instead of infering if
    from the RRSIG length. (#110 by @vavrusa)
  * Canonalize the security algorithm before evaluation to avoid missing
    algorithm provided via the unknown integer variant. (#127 by @vavrusa)
* Support for no-std environments now actually works. (#117 by @Jezza)
* Canonalize IANA types when scanning so that, e.g., CLASS3 becomes
  Class::Ch instead of Class::Int(3). (#127 by @vavrusa)
* resolv: Fixed generation of the domain name to be used for reverse
  IPv6 lookups. (#131)

Other Changes

* Enable doc_cfg feature flag documentation for docs.rs.
  (#104 by Martin Fischer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants