mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-29 07:12:24 +00:00
ts-udpsrc: Creating a gio::Socket from a raw fd/socket is unsafe
So put it into an unsafe block.
This commit is contained in:
parent
9750195caa
commit
3026e56cfb
1 changed files with 8 additions and 12 deletions
|
@ -697,15 +697,13 @@ impl UdpSrc {
|
||||||
|
|
||||||
// Store the socket as used-socket in the settings
|
// Store the socket as used-socket in the settings
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
unsafe {
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
let fd = unsafe { libc::dup(socket.as_raw_fd()) };
|
let fd = libc::dup(socket.as_raw_fd());
|
||||||
|
|
||||||
// This is technically unsafe because it allows
|
// This is unsafe because it allows us to share the fd between the socket and the
|
||||||
// us to share the fd between the socket and the
|
// GIO socket below, but safety of this is the job of the application
|
||||||
// GIO socket below, but safety of this is the
|
|
||||||
// job of the application
|
|
||||||
struct FdConverter(RawFd);
|
struct FdConverter(RawFd);
|
||||||
impl IntoRawFd for FdConverter {
|
impl IntoRawFd for FdConverter {
|
||||||
fn into_raw_fd(self) -> RawFd {
|
fn into_raw_fd(self) -> RawFd {
|
||||||
|
@ -725,13 +723,11 @@ impl UdpSrc {
|
||||||
self.settings.lock().unwrap().used_socket = Some(wrapper);
|
self.settings.lock().unwrap().used_socket = Some(wrapper);
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
unsafe {
|
||||||
let fd = unsafe { dup_socket(socket.as_raw_socket() as _) as _ };
|
let fd = dup_socket(socket.as_raw_socket() as _) as _;
|
||||||
|
|
||||||
// This is technically unsafe because it allows
|
// This is unsafe because it allows us to share the fd between the socket and the
|
||||||
// us to share the fd between the socket and the
|
// GIO socket below, but safety of this is the job of the application
|
||||||
// GIO socket below, but safety of this is the
|
|
||||||
// job of the application
|
|
||||||
struct SocketConverter(RawSocket);
|
struct SocketConverter(RawSocket);
|
||||||
impl IntoRawSocket for SocketConverter {
|
impl IntoRawSocket for SocketConverter {
|
||||||
fn into_raw_socket(self) -> RawSocket {
|
fn into_raw_socket(self) -> RawSocket {
|
||||||
|
|
Loading…
Reference in a new issue