提交 b936cb50 编写于 作者: P Prasad J Pandit 提交者: Riku Voipio

linux-user: allocate heap memory for execve arguments

Arguments passed to execve(2) call from user program could
be large, allocating stack memory for them via alloca(3) call
would lead to bad behaviour. Use 'g_new0' to allocate memory
for such arguments.
Reported-by: NJann Horn <jannh@google.com>
Signed-off-by: NPrasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
上级 c4e316cf
......@@ -7985,8 +7985,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
envc++;
}
argp = alloca((argc + 1) * sizeof(void *));
envp = alloca((envc + 1) * sizeof(void *));
argp = g_new0(char *, argc + 1);
envp = g_new0(char *, envc + 1);
for (gp = guest_argp, q = argp; gp;
gp += sizeof(abi_ulong), q++) {
......@@ -8047,6 +8047,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
unlock_user(*q, addr, 0);
}
g_free(argp);
g_free(envp);
}
break;
case TARGET_NR_chdir:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册