inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
226 stars 39 forks source link

Binary attributes are not properly detected in SearchEntry #109

Closed NivN closed 1 year ago

NivN commented 1 year ago

In the construction of a SearchEntry, attributes are seperated to attrs and bin_attrs hashmap. The code expects std::str::from_utf8 to fail for a binary attribute (search.rs:195), but it may succeed for some binary data. Because of this it is impossible to determine if a binary attribute will appear in attrs or bin attrs since it is affected by the content of the data rather than by the data type.

inejge commented 1 year ago

Documented in the introductory text for SearchEntry:

Since it’s possible that a particular set of values for a binary attribute could be converted into UTF-8 Strings, the presence of such attribute in the result entry should be checked for both in attrs and bin_atrrs.

Short of consulting the schema for every converted attribute, there is no way to tell in advance if an attribute is binary. (Not even schema checking will be foolproof.) So all this works as intended.