]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Zero out the vki_user_regs_struct before using it. Otherwise, we end
authorJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 14:54:09 +0000 (14:54 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 14:54:09 +0000 (14:54 +0000)
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

coregrind/m_debugger.c

index 2943c398335de3e1d38c2511dc8826ab0a372bd6..346d9e704c57715d73b6b242de5bded93799281b 100644 (file)
@@ -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)(&regs, 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)(&regs, 0, sizeof(regs));
    regs.rax    = vex->guest_RAX;
    regs.rbx    = vex->guest_RBX;
    regs.rcx    = vex->guest_RCX;