diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -4249,10 +4249,14 @@ error = copyin(uap->wcred, &wcred32, sizeof(wcred32)); if (error != 0) return (error); - /* These fields have exactly the same sizes and positions. */ - memcpy(&wcred, &wcred32, __rangeof(struct setcred32, - setcred32_copy_start, setcred32_copy_end)); - /* Remaining fields are pointers and need PTRIN*(). */ + memset(&wcred, 0, sizeof(wcred)); + CP(wcred32, wcred, sc_uid); + CP(wcred32, wcred, sc_ruid); + CP(wcred32, wcred, sc_svuid); + CP(wcred32, wcred, sc_gid); + CP(wcred32, wcred, sc_rgid); + CP(wcred32, wcred, sc_svgid); + CP(wcred32, wcred, sc_supp_groups_nb); PTRIN_CP(wcred32, wcred, sc_supp_groups); PTRIN_CP(wcred32, wcred, sc_label); return (user_setcred(td, uap->flags, &wcred)); diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -181,7 +181,6 @@ SETCREDF_MAC_LABEL) struct setcred32 { -#define setcred32_copy_start sc_uid uid_t sc_uid; uid_t sc_ruid; uid_t sc_svuid; @@ -190,7 +189,6 @@ gid_t sc_svgid; u_int sc_pad; u_int sc_supp_groups_nb; -#define setcred32_copy_end sc_supp_groups uint32_t sc_supp_groups; /* gid_t [*] */ uint32_t sc_label; /* struct mac32 [*] */ };