From 2df8aa78d59ab5709e91235b7779456b86830327 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 8 Jan 2008 06:44:19 +0000 Subject: 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 --- libc/unistd/exec.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'libc') 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); -- cgit v1.2.3