statsd-filter-proxy-rs
statsd-filter-proxy-rs copied to clipboard
Calling safe function can lead to undefined behaviour
https://github.com/askldjd/statsd-filter-proxy-rs/blob/6ba64dabc280b3e483a93f29df93688945b7f8fc/src/filter.rs#L4
If &buf isn't valid UTF-8, this results in undefined behaviour. Since filter is not marked as unsafe, it is currently possible to cause undefined behaviour by calling a safe function.
As far as I can tell, this buffer comes from a socket from outside the application, so it is in my opinion a better idea to use the safe str::from_utf8 with proper error handling instead.