diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2016-07-19 05:30:49 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2016-07-19 05:30:49 +0000 |
commit | 0cdc31e8991e3311a3e7129044451dc4c45b8856 (patch) | |
tree | e53e5ab9d781af8b3f9ec4294a1f0f78af08be98 /sys | |
parent | 5e4547689346b7ce4a6ab2a0e6d1d45c43504ff9 (diff) |
instead of messing about with pointer arithmetic, add an empty array
to the end of the defer structure. solves sizing and alignment concerns.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_usrreq.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index ea4c716b0bb..775aedf432e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.99 2016/07/12 14:28:02 tedu Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.100 2016/07/19 05:30:48 tedu Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -64,6 +64,7 @@ struct unp_deferral { SLIST_ENTRY(unp_deferral) ud_link; int ud_n; /* followed by ud_n struct file * pointers */ + struct file *ud_fp[]; }; /* list of sets of files that were sent over sockets that are now closed */ @@ -896,8 +897,7 @@ unp_gc(void *arg __unused) while ((defer = SLIST_FIRST(&unp_deferred)) != NULL) { SLIST_REMOVE_HEAD(&unp_deferred, ud_link); for (i = 0; i < defer->ud_n; i++) { - memcpy(&fp, &((struct file **)(defer + 1))[i], - sizeof(fp)); + fp = defer->ud_fp[i]; if (fp == NULL) continue; FREF(fp); @@ -1059,7 +1059,7 @@ unp_discard(struct file **rp, int nfds) /* copy the file pointers to a deferral structure */ defer = malloc(sizeof(*defer) + sizeof(*rp) * nfds, M_TEMP, M_WAITOK); defer->ud_n = nfds; - memcpy(defer + 1, rp, sizeof(*rp) * nfds); + memcpy(&defer->ud_fp[0], rp, sizeof(*rp) * nfds); memset(rp, 0, sizeof(*rp) * nfds); SLIST_INSERT_HEAD(&unp_deferred, defer, ud_link); |