mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 14:39:09 +08:00
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:
@ -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 (' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user