From 094a24db86ac7b7a4bb66957483ad0050337c92f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 16 Nov 2024 14:30:02 -0600 Subject: [PATCH] Fix a few other array size hacks Sources: * FreeBSD `__reserve_pad`: [1] * NetBSD `accept_filter_arg`: https://man.netbsd.org/setsockopt.2 [1]: https://github.com/freebsd/freebsd-src/blob/4b4e88d9425b59a377a71ffeb553376b1c60a80e/sys/netinet/sctp_uio.h#L110-L146 (apply to `main`) (cherry picked from commit d63be8b69b0736753213f5d933767866a5801ee7) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 9 +++++++-- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 780c7df7d44e1..fd176ce9efab7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1153,7 +1153,7 @@ s! { pub sinfo_assoc_id: ::sctp_assoc_t, pub sinfo_keynumber: u16, pub sinfo_keynumber_valid: u16, - pub __reserve_pad: [[u8; 23]; 4], + pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD], } pub struct sctp_extrcvinfo { @@ -1173,7 +1173,7 @@ s! { pub serinfo_next_ppid: u32, pub sinfo_keynumber: u16, pub sinfo_keynumber_valid: u16, - pub __reserve_pad: [[u8; 19]; 4], + pub __reserve_pad: [u8; SCTP_ALIGN_RESV_PAD_SHORT], } pub struct sctp_sndinfo { @@ -4881,6 +4881,11 @@ pub const SCTP_ASSOC_RESET_FAILED: ::c_int = 0x0008; pub const SCTP_STREAM_CHANGE_DENIED: ::c_int = 0x0004; pub const SCTP_STREAM_CHANGE_FAILED: ::c_int = 0x0008; +// sctp_uio.h + +pub const SCTP_ALIGN_RESV_PAD: usize = 92; +pub const SCTP_ALIGN_RESV_PAD_SHORT: usize = 76; + pub const KENV_DUMP_LOADER: ::c_int = 4; pub const KENV_DUMP_STATIC: ::c_int = 5; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 4997a19af49ae..f9bf0e51258c2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -512,7 +512,7 @@ s! { pub struct accept_filter_arg { pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], + pub af_arg: [::c_char; 256 - 16], } pub struct ki_sigset_t {