aboutsummaryrefslogtreecommitdiff
path: root/binutils/objdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'binutils/objdump.c')
-rw-r--r--binutils/objdump.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 05402ed..16e1f0e 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1982,20 +1982,23 @@ disassemble_bytes (struct disassemble_info * inf,
pb = octets;
for (; j < addr_offset * opb + pb; j += bpc)
{
- int k;
-
- if (bpc > 1 && inf->display_endian == BFD_ENDIAN_LITTLE)
+ /* PR 21619: Check for a buffer ending early. */
+ if (j + bpc <= stop_offset * opb)
{
- 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 (' ');
+ int k;
+
+ 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 (' ');
}
}
}