[binutils-gdb] Fix calculation of space remaining in buffer when printing the contents of a DST__K_RECBEG type debu

Nick Clifton nickc@sourceware.org
Tue Jun 25 10:58:48 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5ac806f22edad7f31098915f0545909e1f0ce6ff

commit 5ac806f22edad7f31098915f0545909e1f0ce6ff
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Jun 25 11:56:38 2024 +0100

    Fix calculation of space remaining in buffer when printing the contents of a DST__K_RECBEG type debug symbol for the VMS Alpha port.
    
      PR 31873

Diff:
---
 bfd/vms-alpha.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 337523015dc..a53ccdf4eb9 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -7721,16 +7721,19 @@ evax_bfd_print_dst (struct bfd *abfd, unsigned int dst_size, FILE *file)
 	case DST__K_RECBEG:
 	  {
 	    struct vms_dst_recbeg *recbeg = (void *)buf;
-	    unsigned char *name = buf + sizeof (*recbeg);
 
 	    if (len > sizeof (*recbeg))
 	      {
+		unsigned char *name = buf + sizeof (*recbeg);
 		int nlen = len - sizeof (*recbeg) - 1;
+
 		if (name[0] < nlen)
 		  nlen = name[0];
 		fprintf (file, _("recbeg: name: %.*s\n"), nlen, name + 1);
+
 		evax_bfd_print_valspec (buf, len, 4, file);
-		len -= 1 + nlen;
+
+		len -= 1 + nlen + sizeof (*recbeg);
 		if (len >= 4)
 		  fprintf (file, _("    len: %u bits\n"),
 			   (unsigned) bfd_getl32 (name + 1 + nlen));


More information about the Binutils-cvs mailing list