Fix address violation when attempting to display disassembled data.
PR binutils/21619 * objdump.c (disassemble_bytes): Check that there is sufficient data available before attempting to display it.
This commit is contained in:
parent
bc21b167eb
commit
d16fdddb4e
2 changed files with 21 additions and 12 deletions
|
@ -1982,20 +1982,23 @@ disassemble_bytes (struct disassemble_info * inf,
|
|||
pb = octets;
|
||||
for (; j < addr_offset * opb + pb; j += bpc)
|
||||
{
|
||||
int k;
|
||||
/* PR 21619: Check for a buffer ending early. */
|
||||
if (j + bpc <= stop_offset * opb)
|
||||
{
|
||||
int k;
|
||||
|
||||
if (bpc > 1 && inf->display_endian == BFD_ENDIAN_LITTLE)
|
||||
{
|
||||
for (k = bpc - 1; k >= 0; k--)
|
||||
printf ("%02x", (unsigned) data[j + k]);
|
||||
putchar (' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
for (k = 0; k < bpc; k++)
|
||||
printf ("%02x", (unsigned) data[j + k]);
|
||||
putchar (' ');
|
||||
if (inf->display_endian == BFD_ENDIAN_LITTLE)
|
||||
{
|
||||
for (k = bpc - 1; k >= 0; k--)
|
||||
printf ("%02x", (unsigned) data[j + k]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (k = 0; k < bpc; k++)
|
||||
printf ("%02x", (unsigned) data[j + k]);
|
||||
}
|
||||
}
|
||||
putchar (' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue