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>
This commit is contained in:
Cyrill Gorcunov 2015-07-19 14:12:44 +03:00
parent ce28db6b68
commit 2e6297ff1b
7 changed files with 14 additions and 0 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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"

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {