Stop potential illegal memory access in the NS32K disassembler.
* ns32k-dis.c (bit_extract): Add sanitiy check of parameters. (bit_extract_simple): Likewise. (bit_copy): Likewise. (pirnt_insn_ns32k): Ensure that uninitialised elements in the index_offset array are not accessed.
This commit is contained in:
parent
dee334510f
commit
d1e304bc27
2 changed files with 17 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2019-10-28 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* ns32k-dis.c (bit_extract): Add sanitiy check of parameters.
|
||||||
|
(bit_extract_simple): Likewise.
|
||||||
|
(bit_copy): Likewise.
|
||||||
|
(pirnt_insn_ns32k): Ensure that uninitialised elements in the
|
||||||
|
index_offset array are not accessed.
|
||||||
|
|
||||||
2019-10-28 Nick Clifton <nickc@redhat.com>
|
2019-10-28 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* xgate-dis.c (print_insn): Fix decoding of the XGATE_OP_DYA
|
* xgate-dis.c (print_insn): Fix decoding of the XGATE_OP_DYA
|
||||||
|
|
|
@ -265,6 +265,8 @@ bit_extract (bfd_byte *buffer, int offset, int count)
|
||||||
int result;
|
int result;
|
||||||
int bit;
|
int bit;
|
||||||
|
|
||||||
|
if (offset < 0 || count < 0)
|
||||||
|
return 0;
|
||||||
buffer += offset >> 3;
|
buffer += offset >> 3;
|
||||||
offset &= 7;
|
offset &= 7;
|
||||||
bit = 1;
|
bit = 1;
|
||||||
|
@ -292,6 +294,8 @@ bit_extract_simple (bfd_byte *buffer, int offset, int count)
|
||||||
int result;
|
int result;
|
||||||
int bit;
|
int bit;
|
||||||
|
|
||||||
|
if (offset < 0 || count < 0)
|
||||||
|
return 0;
|
||||||
buffer += offset >> 3;
|
buffer += offset >> 3;
|
||||||
offset &= 7;
|
offset &= 7;
|
||||||
bit = 1;
|
bit = 1;
|
||||||
|
@ -313,6 +317,8 @@ bit_extract_simple (bfd_byte *buffer, int offset, int count)
|
||||||
static void
|
static void
|
||||||
bit_copy (bfd_byte *buffer, int offset, int count, char *to)
|
bit_copy (bfd_byte *buffer, int offset, int count, char *to)
|
||||||
{
|
{
|
||||||
|
if (offset < 0 || count < 0)
|
||||||
|
return;
|
||||||
for (; count > 8; count -= 8, to++, offset += 8)
|
for (; count > 8; count -= 8, to++, offset += 8)
|
||||||
*to = bit_extract (buffer, offset, 8);
|
*to = bit_extract (buffer, offset, 8);
|
||||||
*to = bit_extract (buffer, offset, count);
|
*to = bit_extract (buffer, offset, count);
|
||||||
|
@ -836,8 +842,10 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
|
||||||
memaddr, arg_bufs[argnum],
|
memaddr, arg_bufs[argnum],
|
||||||
index_offset[whicharg]);
|
index_offset[whicharg]);
|
||||||
d++;
|
d++;
|
||||||
whicharg++;
|
if (whicharg++ >= 1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (argnum = 0; argnum <= maxarg; argnum++)
|
for (argnum = 0; argnum <= maxarg; argnum++)
|
||||||
{
|
{
|
||||||
bfd_vma addr;
|
bfd_vma addr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue