From f7341ff4006dd90ffc6560bb9db761b9d2950aaf Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 30 Mar 2003 21:00:25 +0000 Subject: [PATCH] fixed execve bug git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@67 c046a42c-6fe2-441c-8c8c-71466251a162 --- linux-user/syscall.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index befc08dd31..898dbcdf03 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1077,7 +1077,6 @@ int do_vm86(CPUX86State *env, long subfunction, } ts->target_v86 = target_v86; - /* save current CPU regs */ ts->vm86_saved_regs.eax = 0; /* default vm86 syscall return code */ ts->vm86_saved_regs.ebx = env->regs[R_EBX]; @@ -1239,22 +1238,27 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, case TARGET_NR_execve: { char **argp, **envp; - int argc = 0, envc = 0; + int argc, envc; uint32_t *p; char **q; + argc = 0; for (p = (void *)arg2; *p; p++) argc++; + envc = 0; for (p = (void *)arg3; *p; p++) envc++; - argp = alloca(argc * sizeof(void *)); - envp = alloca(envc * sizeof(void *)); + argp = alloca((argc + 1) * sizeof(void *)); + envp = alloca((envc + 1) * sizeof(void *)); for (p = (void *)arg2, q = argp; *p; p++, q++) *q = (void *)tswap32(*p); + *q = NULL; + for (p = (void *)arg3, q = envp; *p; p++, q++) *q = (void *)tswap32(*p); + *q = NULL; ret = get_errno(execve((const char *)arg1, argp, envp)); } -- GitLab