PR31873, buffer overflow in evax_bfd_print_dst

Message ID ZmcAe60FAU_G8RlW@squeak.grove.modra.org
State New
Headers
Series PR31873, buffer overflow in evax_bfd_print_dst |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 warning Patch is already merged

Commit Message

Alan Modra June 10, 2024, 1:32 p.m. UTC
  PR 31873
	* vms-alpha.c (evax_bfd_print_dst): Sanity check len against
	dst_size.
  

Patch

diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 404638cf3d9..337523015dc 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -7511,6 +7511,8 @@  evax_bfd_print_dst (struct bfd *abfd, unsigned int dst_size, FILE *file)
       /* xgettext:c-format */
       fprintf (file, _(" type: %3u, len: %3u (at 0x%08x): "),
 	       type, len, off);
+      if (len > dst_size)
+	len = dst_size;
       if (len < sizeof (dsth))
 	{
 	  fputc ('\n', file);