From 4118a97030aa9bd1d520d1d06bbe0655d829df04 Mon Sep 17 00:00:00 2001 From: j_mayer Date: Thu, 27 Sep 2007 04:10:43 +0000 Subject: memset string pages to zero to avoid putting random data on the stack that may make some program crash at startup. Fix unsigned long / target_ulong confusion (more to do). Fix missing g2h macros. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3249 c046a42c-6fe2-441c-8c8c-71466251a162 --- linux-user/elfload.c | 3 ++- linux-user/mmap.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'linux-user') diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 2a43338125..22e3283ae7 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -517,7 +517,7 @@ static void bswap_sym(struct elf_sym *sym) * */ static unsigned long copy_elf_strings(int argc,char ** argv, void **page, - unsigned long p) + target_ulong p) { char *tmp, *tmp1, *pag = NULL; int len, offset = 0; @@ -544,6 +544,7 @@ static unsigned long copy_elf_strings(int argc,char ** argv, void **page, pag = (char *)page[p/TARGET_PAGE_SIZE]; if (!pag) { pag = (char *)malloc(TARGET_PAGE_SIZE); + memset(pag, 0, TARGET_PAGE_SIZE); page[p/TARGET_PAGE_SIZE] = pag; if (!pag) return 0; diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 28954f13fa..29f1d9625c 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -224,9 +224,9 @@ abort(); start = HOST_PAGE_ALIGN(real_start); end = start + HOST_PAGE_ALIGN(len); if (start > real_start) - munmap((void *)real_start, start - real_start); + munmap((void *)g2h(real_start), start - real_start); if (end < real_end) - munmap((void *)end, real_end - end); + munmap((void *)g2h(end), real_end - end); /* use it as a fixed mapping */ flags |= MAP_FIXED; } else { @@ -370,7 +370,7 @@ int target_munmap(target_ulong start, target_ulong len) /* unmap what we can */ if (real_start < real_end) { - ret = munmap((void *)real_start, real_end - real_start); + ret = munmap(g2h(real_start), real_end - real_start); if (ret != 0) return ret; } -- cgit v1.2.3