eminence / udt-rs

UDT bindings for Rust
BSD 2-Clause "Simplified" License
32 stars 12 forks source link

Raw descriptors are not handled safely #11

Closed ustulation closed 6 years ago

ustulation commented 6 years ago

This and this are not safe. The correct way should have been into_raw...() instead of as_raw...(). Otherwise the function is taking the ownership of the supplied socket but then does not cause an "into" from it. So at the end of the function the socket is going to be dropped leaving the obtained descriptor dangling. This might lead to Undefined Behaviour. So we should use the into_... set of functions really IMO.

eminence commented 6 years ago

Thanks, I'll take a look.

This code-base was written several years ago, and will benefit from a good review. So thank you for bringing a set of fresh eyes to this code.

ustulation commented 6 years ago

Ah np, i'll keep the issues coming as i use/read it and think something is worthy of getting flagged. It's already a good crate binding to a C++ interface - quite useful :)