mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-03-01 13:26:47 +08:00
sim/ppc: initialize a memory buffer in all cases
In the ppc simulator's do_fstat function, which provides the fstat call for the simulator, if the fstat is going to fail then we currently write an uninitialized buffer into the simulated target. In theory, I think this is fine, we also write the error status into the simulated target, so, given that the fstat has failed, the target shouldn't be relying on the buffer contents. However, writing an uninitialized buffer means we might leak simulator private data into the simulated target, which is probably a bad thing. Plus it probably makes life easier if something consistent, like all zeros, is written rather than random junk, which might look like a successful call (except for the error code). So, in this commit, I initialize the stat buffer to zero before it is potentially used. If the stat call is not made then the buffer will be left initialized as all zeros.
This commit is contained in:
parent
368b8c3259
commit
548d634f1b
@ -879,7 +879,7 @@ do_fstat(os_emul_data *emul,
|
|||||||
{
|
{
|
||||||
int fd = cpu_registers(processor)->gpr[arg0];
|
int fd = cpu_registers(processor)->gpr[arg0];
|
||||||
unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1];
|
unsigned_word stat_buf_addr = cpu_registers(processor)->gpr[arg0+1];
|
||||||
struct stat buf;
|
struct stat buf = {};
|
||||||
int status;
|
int status;
|
||||||
#ifdef SYS_fstat
|
#ifdef SYS_fstat
|
||||||
SYS(fstat);
|
SYS(fstat);
|
||||||
|
Loading…
Reference in New Issue
Block a user