summaryrefslogtreecommitdiff
path: root/libc/unistd/exec.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-01-08 06:44:19 +0000
committerMike Frysinger <vapier@gentoo.org>2008-01-08 06:44:19 +0000
commit2df8aa78d59ab5709e91235b7779456b86830327 (patch)
tree6b4083cff2408ad17d6d706d6b854210d32418ab /libc/unistd/exec.c
parent94fa1bb40fb531a71f7f751afcf96c4ad2f99591 (diff)
fix memory corruption on no-mmu from doing multiple execls where earlier execls fail by simply not releasing the memory reserved for the arguments of children processes
Diffstat (limited to 'libc/unistd/exec.c')
-rw-r--r--libc/unistd/exec.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c
index 381a81464..11807a8a7 100644
--- a/libc/unistd/exec.c
+++ b/libc/unistd/exec.c
@@ -63,19 +63,12 @@ libc_hidden_proto(getenv)
# define EXEC_ALLOC_SIZE(VAR) size_t VAR; /* Semicolon included! */
# define EXEC_ALLOC(SIZE,VAR) __exec_alloc((VAR = (SIZE)))
-# define EXEC_FREE(PTR,VAR) __exec_free((PTR),(VAR))
+# define EXEC_FREE(PTR,VAR) ((void)0)
extern void *__exec_alloc(size_t size) attribute_hidden;
-extern void __exec_free(void *ptr, size_t size) attribute_hidden;
# ifdef L___exec_alloc
-void attribute_hidden __exec_free(void *ptr, size_t size)
-{
- if (ptr)
- munmap(ptr, size);
-}
-
void attribute_hidden *__exec_alloc(size_t size)
{
static void *p;
@@ -83,8 +76,8 @@ void attribute_hidden *__exec_alloc(size_t size)
if (old_size >= size)
return p;
- else
- __exec_free(p, old_size);
+ else if (p)
+ munmap(p, old_size);
old_size = size;
p = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);