Skip to content

Commit

Permalink
dump: Fix writing of ELF section
Browse files Browse the repository at this point in the history
In write_elf_section() we set the 'shdr' pointer to point to local
structures shdr32 or shdr64, which we fill in to be written out to
the ELF dump.  Unfortunately the address we pass to fd_write_vmcore()
has a spurious '&' operator, so instead of writing out the section
header we write out the literal pointer value followed by whatever is
on the stack after the 'shdr' local variable.

Pass the correct address into fd_write_vmcore().

Spotted by Coverity: CID 1421970.

Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200324173630.12221-1-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Apr 3, 2020
1 parent c88311f commit 174d2d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dump/dump.c
Expand Up @@ -364,7 +364,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp)
shdr = &shdr64;
}

ret = fd_write_vmcore(&shdr, shdr_size, s);
ret = fd_write_vmcore(shdr, shdr_size, s);
if (ret < 0) {
error_setg_errno(errp, -ret,
"dump: failed to write section header table");
Expand Down

0 comments on commit 174d2d6

Please sign in to comment.