Skip to content

Commit

Permalink
As zone signing assumes, but does not check, that the zone is ordered…
Browse files Browse the repository at this point in the history
…, add a check in debug builds (not in release builds as it is too costly) if the zone is correctly sorted before signing.
  • Loading branch information
ximon18 committed Jan 9, 2025
1 parent 681456a commit b1f7a20
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ where

//------------ sign_zone() ---------------------------------------------------

/// DNSSEC sign the given zone records.
///
/// Assumes that the given zone records are sorted according to
/// [`CanonicalOrd`]. The behaviour is undefined otherwise.
///
/// # Panics
///
/// This function will panic in debug builds if the given zone is not sorted
/// according to [`CanonicalOrd`].
pub fn sign_zone<N, Octs, S, DSK, Inner, KeyStrat, Sort, HP, T>(
mut in_out: SignableZoneInOut<N, Octs, S, T, Sort>,
apex: &N,
Expand Down Expand Up @@ -435,6 +444,8 @@ where
return Err(SigningError::NoSoaFound);
};

debug_assert!(in_out.as_slice().is_sorted_by(CanonicalOrd::canonical_le));

Check failure on line 447 in src/sign/mod.rs

View workflow job for this annotation

GitHub Actions / Build examples (1.78.0)

use of unstable library feature 'is_sorted': new API

Check failure on line 447 in src/sign/mod.rs

View workflow job for this annotation

GitHub Actions / Check minimal versions

use of unstable library feature 'is_sorted': new API

Check failure on line 447 in src/sign/mod.rs

View workflow job for this annotation

GitHub Actions / Check minimal versions

expected `for<'a, 'b> fn(&'a Record<N, ZoneRecordData<Octs, N>>, &'b Record<N, ZoneRecordData<Octs, N>>) -> bool {<Record<N, ZoneRecordData<Octs, N>> as CanonicalOrd>::canonical_le}` to be a fn item that returns `Option<Ordering>`, but it returns `bool`

Check failure on line 447 in src/sign/mod.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

current MSRV (Minimum Supported Rust Version) is `1.68.2` but this item is stable since `1.82.0`

Check failure on line 447 in src/sign/mod.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, stable)

current MSRV (Minimum Supported Rust Version) is `1.68.2` but this item is stable since `1.82.0`

// RFC 9077 updated RFC 4034 (NSEC) and RFC 5155 (NSEC3) to say that
// the "TTL of the NSEC(3) RR that is returned MUST be the lesser of
// the MINIMUM field of the SOA record and the TTL of the SOA itself".
Expand Down

0 comments on commit b1f7a20

Please sign in to comment.