From: Julian Seward Date: Mon, 19 Nov 2007 14:54:09 +0000 (+0000) Subject: Zero out the vki_user_regs_struct before using it. Otherwise, we end X-Git-Tag: svn/VALGRIND_3_3_0~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04ac736514f5a45a1661b5525a0a649eec5feb47;p=thirdparty%2Fvalgrind.git Zero out the vki_user_regs_struct before using it. Otherwise, we end up passing uninitialised garbage on the stack to ptrace(SETREGS, ...) for any fields in the struct which are not filled in. This does not fix any known bugs, but seems like a good precautionary measure. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7187 --- diff --git a/coregrind/m_debugger.c b/coregrind/m_debugger.c index 2943c39833..346d9e704c 100644 --- a/coregrind/m_debugger.c +++ b/coregrind/m_debugger.c @@ -49,6 +49,7 @@ static Int ptrace_setregs(Int pid, VexGuestArchState* vex) { #if defined(VGP_x86_linux) struct vki_user_regs_struct regs; + VG_(memset)(®s, 0, sizeof(regs)); regs.cs = vex->guest_CS; regs.ss = vex->guest_SS; regs.ds = vex->guest_DS; @@ -69,6 +70,7 @@ static Int ptrace_setregs(Int pid, VexGuestArchState* vex) #elif defined(VGP_amd64_linux) struct vki_user_regs_struct regs; + VG_(memset)(®s, 0, sizeof(regs)); regs.rax = vex->guest_RAX; regs.rbx = vex->guest_RBX; regs.rcx = vex->guest_RCX;