NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
332 stars 56 forks source link

Domain name compression is broken in 0.10.0 #321

Closed hunts closed 1 month ago

hunts commented 1 month ago

There is a bug in SliceLabelsIter's next() implement that is causing it not able to return the full/right labels in the octets slice.

StaticCompressor leverages SliceLabelsIter to search known domain names in the underlying octets, is not able to find existing names because of this. Thus, leading to broken domain name compression in 0.10.0.

hunts commented 1 month ago

I see Label has a compose_len() function, but it is trying to return a u16, meanwhile there are label.len() + 1 in several places in the codebase. It may worth a new issue to update all of these, but I'm going for label.len() + 1 for now.

partim commented 1 month ago

Thank you for the PR!

This actually used to use compose_len – I probably broke it when changing that function to return a u16.