summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2000-09-26 14:01:40 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2000-09-26 14:01:40 +0000
commita4ba45aa8ff49696e29a6ed776ac4323979b6a0b (patch)
treefde7f3340ff238f94942119a6bee96120583eb00 /sys
parentfe62e6305dc011bf50462c95485e56f7726e049d (diff)
Don't use MALLOC/FREE on variable sized allocations.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/exec_script.c10
-rw-r--r--sys/kern/exec_subr.c11
-rw-r--r--sys/kern/kern_exec.c12
3 files changed, 16 insertions, 17 deletions
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c
index 5dd95822722..860ad936ffc 100644
--- a/sys/kern/exec_script.c
+++ b/sys/kern/exec_script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_script.c,v 1.10 2000/02/01 04:03:14 assar Exp $ */
+/* $OpenBSD: exec_script.c,v 1.11 2000/09/26 14:01:38 art Exp $ */
/* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */
/*
@@ -191,13 +191,13 @@ check_shell:
/* and set up the fake args list, for later */
MALLOC(shellargp, char **, 4 * sizeof(char *), M_EXEC, M_WAITOK);
tmpsap = shellargp;
- MALLOC(*tmpsap, char *, shellnamelen + 1, M_EXEC, M_WAITOK);
+ *tmpsap = malloc(shellnamelen + 1, M_EXEC, M_WAITOK);
strcpy(*tmpsap++, shellname);
if (shellarg != NULL) {
- MALLOC(*tmpsap, char *, shellarglen + 1, M_EXEC, M_WAITOK);
+ *tmpsap = malloc(shellarglen + 1, M_EXEC, M_WAITOK);
strcpy(*tmpsap++, shellarg);
}
- MALLOC(*tmpsap, char *, MAXPATHLEN, M_EXEC, M_WAITOK);
+ *tmpsap = malloc(MAXPATHLEN, M_EXEC, M_WAITOK);
#ifdef FDSCRIPTS
if ((epp->ep_flags & EXEC_HASFD) == 0) {
#endif
@@ -281,7 +281,7 @@ fail:
/* free the fake arg list, because we're not returning it */
tmpsap = shellargp;
while (*tmpsap != NULL) {
- FREE(*tmpsap, M_EXEC);
+ free(*tmpsap, M_EXEC);
tmpsap++;
}
FREE(shellargp, M_EXEC);
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index d29f31884f6..0829a80746e 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.7 1999/11/05 01:18:01 mickey Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.8 2000/09/26 14:01:39 art Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -99,13 +99,12 @@ vmcmdset_extend(evsp)
evsp->evs_cnt += ocnt ? ocnt : EXEC_DEFAULT_VMCMD_SETSIZE;
/* allocate it */
- MALLOC(nvcp, struct exec_vmcmd *,
- (evsp->evs_cnt * sizeof(struct exec_vmcmd)), M_EXEC, M_WAITOK);
-
+ nvcp = malloc(evsp->evs_cnt * sizeof(struct exec_vmcmd), M_EXEC,
+ M_WAITOK);
/* free the old struct, if there was one, and record the new one */
if (ocnt) {
bcopy(evsp->evs_cmds, nvcp, (ocnt * sizeof(struct exec_vmcmd)));
- FREE(evsp->evs_cmds, M_EXEC);
+ free(evsp->evs_cmds, M_EXEC);
}
evsp->evs_cmds = nvcp;
}
@@ -126,7 +125,7 @@ kill_vmcmds(evsp)
vrele(vcp->ev_vp);
}
evsp->evs_used = evsp->evs_cnt = 0;
- FREE(evsp->evs_cmds, M_EXEC);
+ free(evsp->evs_cmds, M_EXEC);
}
/*
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index b5de0c02c0d..098edd5049e 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.42 2000/04/20 10:03:42 art Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.43 2000/09/26 14:01:39 art Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -263,7 +263,7 @@ sys_execve(p, v, retval)
* initialize the fields of the exec package.
*/
pack.ep_name = (char *)SCARG(uap, path);
- MALLOC(pack.ep_hdr, void *, exec_maxhdrsz, M_EXEC, M_WAITOK);
+ pack.ep_hdr = malloc(exec_maxhdrsz, M_EXEC, M_WAITOK);
pack.ep_hdrlen = exec_maxhdrsz;
pack.ep_hdrvalid = 0;
pack.ep_ndp = &nid;
@@ -305,7 +305,7 @@ sys_execve(p, v, retval)
*dp++ = *cp++;
dp++;
- FREE(*tmpfap, M_EXEC);
+ free(*tmpfap, M_EXEC);
tmpfap++; argc++;
}
FREE(pack.ep_fa, M_EXEC);
@@ -601,7 +601,7 @@ sys_execve(p, v, retval)
psignal(p, SIGTRAP);
p->p_emul = pack.ep_emul;
- FREE(pack.ep_hdr, M_EXEC);
+ free(pack.ep_hdr, M_EXEC);
#ifdef KTRACE
if (KTRPOINT(p, KTR_EMUL))
@@ -628,7 +628,7 @@ bad:
#endif
freehdr:
- FREE(pack.ep_hdr, M_EXEC);
+ free(pack.ep_hdr, M_EXEC);
return (error);
exec_abort:
@@ -656,7 +656,7 @@ exec_abort:
#endif
free_pack_abort:
- FREE(pack.ep_hdr, M_EXEC);
+ free(pack.ep_hdr, M_EXEC);
exit1(p, W_EXITCODE(0, SIGABRT));
exit1(p, -1);