diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-03-30 21:00:25 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-03-30 21:00:25 +0000 |
commit | f7341ff4006dd90ffc6560bb9db761b9d2950aaf (patch) | |
tree | 722125cc777a3bb2ff25ca9f6f919025d8a9e86a /linux-user/syscall.c | |
parent | fd429f2f6cbc77dc5440725ede80df614787ece3 (diff) |
fixed execve bug
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@67 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 12 |
1 files 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)); } |