Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b60a013

Browse files
committedAug 19, 2023
Prevent safe construction of struct sigevent
sigevent's Debug, PartialEq, and Hash trait impls might read union fields that could be potentially uninitialized by a standard initializer. Those trait impls shouldn't be present (see rust-lang#2816), but can't easily be removed. Until they get removed, the constructor must be `unsafe` to force the user to zero all fields. The same issue applies to the Deref<Target=sigevent_0_2_126> trait impl, which exists only for backwards compatibility.
1 parent 24c4805 commit b60a013

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎src/unix/bsd/freebsdlike/freebsd/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,12 @@ s_no_extra_traits! {
14101410
pub sigev_signo: ::c_int,
14111411
pub sigev_value: ::sigval,
14121412
pub _sigev_un: __c_anonymous_sigev_un,
1413+
/// Exists just to prevent the struct from being safely constructed,
1414+
/// because the Debug, Hash, PartialImpl, and
1415+
/// Deref<Target=sigevent_0_2_0126> trait impls might read uninitialized
1416+
/// fields of _sigev_un. This field may be removed once those trait
1417+
/// impls are.
1418+
_private: ()
14131419
}
14141420

14151421
pub struct ptsstat {

‎src/unix/linux_like/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ s_no_extra_traits! {
291291
pub sigev_signo: ::c_int,
292292
pub sigev_notify: ::c_int,
293293
pub _sigev_un: __c_anonymous_sigev_un,
294+
/// Exists just to prevent the struct from being safely constructed,
295+
/// because the Debug, Hash, PartialImpl, and
296+
/// Deref<Target=sigevent_0_2_0126> trait impls might read uninitialized
297+
/// fields of _sigev_un. This field may be removed once those trait
298+
/// impls are.
299+
_private: ()
294300
}
295301
}
296302

0 commit comments

Comments
 (0)