summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-09-05 10:28:44 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-09-05 10:28:44 +0000
commitc6c9cb6c61f234ebb1ac3728fd39f4dc41b7cf1d (patch)
tree8d9acd63ec64a74047112fc59ac1aed253a3d620 /sys
parent3827cf56b00ca00fc161a595b725a2456190dd23 (diff)
Fix various cases of stackgap_alloc() size arguments not being computed
correctly, usually yielding the right value on 32 bit machines because sizeof int == sizeof pointer.
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c16
-rw-r--r--sys/compat/linux/linux_ipc.c4
-rw-r--r--sys/compat/linux/linux_misc.c4
-rw-r--r--sys/compat/linux/linux_socket.c4
4 files changed, 14 insertions, 14 deletions
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
index df76d5cd1e1..6eae6b7b56a 100644
--- a/sys/compat/ibcs2/ibcs2_misc.c
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_misc.c,v 1.29 2007/09/01 15:14:44 martin Exp $ */
+/* $OpenBSD: ibcs2_misc.c,v 1.30 2009/09/05 10:28:41 miod Exp $ */
/* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */
/*
@@ -535,7 +535,7 @@ ibcs2_sys_getgroups(p, v, retval)
SCARG(&sa, gidsetsize) = SCARG(uap, gidsetsize);
if (SCARG(uap, gidsetsize)) {
SCARG(&sa, gidset) = stackgap_alloc(&sg, NGROUPS_MAX *
- sizeof(gid_t *));
+ sizeof(gid_t));
iset = stackgap_alloc(&sg, SCARG(uap, gidsetsize) *
sizeof(ibcs2_gid_t));
}
@@ -569,12 +569,12 @@ ibcs2_sys_setgroups(p, v, retval)
caddr_t sg = stackgap_init(p->p_emul);
SCARG(&sa, gidsetsize) = SCARG(uap, gidsetsize);
- gp = stackgap_alloc(&sg, SCARG(&sa, gidsetsize) * sizeof(gid_t *));
+ gp = stackgap_alloc(&sg, SCARG(&sa, gidsetsize) * sizeof(gid_t));
iset = stackgap_alloc(&sg, SCARG(&sa, gidsetsize) *
- sizeof(ibcs2_gid_t *));
+ sizeof(ibcs2_gid_t));
if (SCARG(&sa, gidsetsize)) {
error = copyin((caddr_t)SCARG(uap, gidset), (caddr_t)iset,
- sizeof(ibcs2_gid_t *) * SCARG(uap, gidsetsize));
+ sizeof(ibcs2_gid_t) * SCARG(uap, gidsetsize));
if (error)
return error;
}
@@ -708,7 +708,7 @@ ibcs2_sys_sysconf(p, v, retval)
caddr_t sg = stackgap_init(p->p_emul);
SCARG(&ga, which) = RLIMIT_NPROC;
- SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit));
if ((error = sys_getrlimit(p, &ga, retval)) != 0)
return error;
*retval = SCARG(&ga, rlp)->rlim_cur;
@@ -728,7 +728,7 @@ ibcs2_sys_sysconf(p, v, retval)
caddr_t sg = stackgap_init(p->p_emul);
SCARG(&ga, which) = RLIMIT_NOFILE;
- SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit));
if ((error = sys_getrlimit(p, &ga, retval)) != 0)
return error;
*retval = SCARG(&ga, rlp)->rlim_cur;
@@ -922,7 +922,7 @@ ibcs2_sys_utime(p, v, retval)
struct timeval *tp;
caddr_t sg = stackgap_init(p->p_emul);
- tp = stackgap_alloc(&sg, 2 * sizeof(struct timeval *));
+ tp = stackgap_alloc(&sg, 2 * sizeof(struct timeval));
IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&sa, path) = SCARG(uap, path);
if (SCARG(uap, buf)) {
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
index f3a16bb0171..4183249af6a 100644
--- a/sys/compat/linux/linux_ipc.c
+++ b/sys/compat/linux/linux_ipc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_ipc.c,v 1.10 2007/05/29 10:44:29 sturm Exp $ */
+/* $OpenBSD: linux_ipc.c,v 1.11 2009/09/05 10:28:43 miod Exp $ */
/* $NetBSD: linux_ipc.c,v 1.10 1996/04/05 00:01:44 christos Exp $ */
/*
@@ -328,7 +328,7 @@ linux_semctl(p, v, retval)
return sys___semctl(p, &bsa, retval);
case LINUX_IPC_STAT:
sg = stackgap_init(p->p_emul);
- unptr = stackgap_alloc(&sg, sizeof (union semun *));
+ unptr = stackgap_alloc(&sg, sizeof (union semun));
dsp = stackgap_alloc(&sg, sizeof (struct semid_ds));
if ((error = copyout((caddr_t)&dsp, unptr, sizeof dsp)))
return error;
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index ff7c5cc63a9..8c68145736a 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_misc.c,v 1.62 2008/06/26 05:42:14 ray Exp $ */
+/* $OpenBSD: linux_misc.c,v 1.63 2009/09/05 10:28:43 miod Exp $ */
/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */
/*-
@@ -153,7 +153,7 @@ linux_sys_wait4(p, v, retval)
if (SCARG(uap, status) != NULL) {
sg = stackgap_init(p->p_emul);
- status = (int *) stackgap_alloc(&sg, sizeof status);
+ status = (int *) stackgap_alloc(&sg, sizeof *status);
} else
status = NULL;
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 0bb32291d9d..861fc69853c 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_socket.c,v 1.38 2009/02/19 19:04:34 deraadt Exp $ */
+/* $OpenBSD: linux_socket.c,v 1.39 2009/09/05 10:28:43 miod Exp $ */
/* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */
/*
@@ -312,7 +312,7 @@ linux_connect(p, v, retval)
#endif
status = stackgap_alloc(&sg, sizeof stat);
- statusl = stackgap_alloc(&sg, sizeof statusl);
+ statusl = stackgap_alloc(&sg, sizeof statl);
if ((error = copyout(&statl, statusl, sizeof statl)))
return error;