mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-23 17:29:23 +08:00
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:
parent
ce28db6b68
commit
2e6297ff1b
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user