[binutils-gdb] PR 34418 alpha_vms_slurp_relocs off-by-one section index check

Alan Modra via Binutils-cvs <[email protected]> Wed, 22 Jul 2026 08:52:46 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Debe2f2b098a5=
62b0f19ca99856df7793cd1dcc67

commit ebe2f2b098a562b0f19ca99856df7793cd1dcc67
Author: Alan Modra <[email protected]>
Date:   Wed Jul 22 18:20:37 2026 +0930

    PR 34418 alpha_vms_slurp_relocs off-by-one section index check
   =20
            * vms-alpha.c (alpha_vms_slurp_relocs): Make cur_psect unsigned.
            Correct cur_psect bounds check.

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

diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 24b05f90bea..d07660df0a7 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -5281,7 +5281,7 @@ alpha_vms_canonicalize_symtab (bfd *abfd, asymbol **s=
ymbols)
 static bool
 alpha_vms_slurp_relocs (bfd *abfd)
 {
-  int cur_psect =3D -1;
+  unsigned int cur_psect =3D -1u;
=20
   vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
=20
@@ -5525,7 +5525,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
 	    bfd_size_type size;
=20
 	    /* Get section to which the relocation applies.  */
-	    if (cur_psect < 0 || cur_psect > (int)PRIV (section_count))
+	    if (cur_psect >=3D PRIV (section_count))
 	      {
 		_bfd_error_handler (_("invalid section index in ETIR"));
 		goto fail;