diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2015-07-19 14:12:44 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2015-07-19 14:24:26 +0300 |
commit | 2e6297ff1b025e2a6c9878febe2574d3dea110da (patch) | |
tree | 7235f0282a8e8651e3588ae787c0bef9ad5063f3 | |
parent | ce28db6b688480cb46a33c29da857e1959abbd8d (diff) | |
download | nasm-2e6297ff1b025e2a6c9878febe2574d3dea110da.tar.gz |
out: Zeroify temp buffer before use
This is a a buffer on stack big enough to hold
bigger object we might need (address, number and
etc) but it's defined as an array of bytes and
we treat it as different types depending on context,
which may lead to situation where data from stack
been treated as meaningful.
In particular in commit 5b730a197 we've fixed such
problem simply using a "big" write to zeroify stack
data before use.
Lets simply zeroify this buffer explicitly to escape
such problems in future.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r-- | output/outaout.c | 2 | ||||
-rw-r--r-- | output/outas86.c | 2 | ||||
-rw-r--r-- | output/outbin.c | 2 | ||||
-rw-r--r-- | output/outcoff.c | 2 | ||||
-rw-r--r-- | output/outelf32.c | 2 | ||||
-rw-r--r-- | output/outmac32.c | 2 | ||||
-rw-r--r-- | output/outmac64.c | 2 |
7 files changed, 14 insertions, 0 deletions
diff --git a/output/outaout.c b/output/outaout.c index 860b8a8b..cbd7ef15 100644 --- a/output/outaout.c +++ b/output/outaout.c @@ -622,6 +622,8 @@ static void aout_out(int32_t segto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + if (type == OUT_RESERVE) { if (s) { nasm_error(ERR_WARNING, "uninitialized space declared in" diff --git a/output/outas86.c b/output/outas86.c index 95675ef8..a800e90f 100644 --- a/output/outas86.c +++ b/output/outas86.c @@ -330,6 +330,8 @@ static void as86_out(int32_t segto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + if (type == OUT_RESERVE) { if (s) { nasm_error(ERR_WARNING, "uninitialized space declared in" diff --git a/output/outbin.c b/output/outbin.c index 76a00a82..77a9778f 100644 --- a/output/outbin.c +++ b/output/outbin.c @@ -542,6 +542,8 @@ static void bin_cleanup(int debuginfo) nasm_assert(r->bytes <= 8); + memset(mydata, 0, sizeof(mydata)); + saa_fread(r->target->contents, r->posn, mydata, r->bytes); p = mydata; l = 0; diff --git a/output/outcoff.c b/output/outcoff.c index d813f5d2..2d55fd09 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -634,6 +634,8 @@ static void coff_out(int32_t segto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + if (type == OUT_RESERVE) { if (s->data) { nasm_error(ERR_WARNING, "uninitialised space declared in" diff --git a/output/outelf32.c b/output/outelf32.c index c1c8b82f..e810198c 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -709,6 +709,8 @@ static void elf_out(int32_t segto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + switch (type) { case OUT_RESERVE: if (s->type == SHT_PROGBITS) { diff --git a/output/outmac32.c b/output/outmac32.c index 616211eb..0cd06ef0 100644 --- a/output/outmac32.c +++ b/output/outmac32.c @@ -410,6 +410,8 @@ static void macho_output(int32_t secto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + switch (type) { case OUT_RESERVE: if (s != sbss) { diff --git a/output/outmac64.c b/output/outmac64.c index 461fa326..1492704b 100644 --- a/output/outmac64.c +++ b/output/outmac64.c @@ -511,6 +511,8 @@ static void macho_output(int32_t secto, const void *data, return; } + memset(mydata, 0, sizeof(mydata)); + switch (type) { case OUT_RESERVE: if (s != sbss) { |