Re: Bug 23686, two segment faults in nm
authorAlan Modra <amodra@gmail.com>
Sat, 20 May 2023 11:30:25 +0000 (21:00 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 20 May 2023 11:36:03 +0000 (21:06 +0930)
The fix for pr23686 had a hole in the reloc address sanity check,
the calculation could overflow.  Note that stabsize is known to be a
non-zero multiple of 12 so stabsize - 4 can't underflow.

PR 23686
* syms.c (_bfd_stab_section_find_nearest_line): Correct
r->address sanity check.

bfd/syms.c

index 6979096fbc645109754efe9564d21a1c54ad0c54..d756995d76726b08403bfe7c24d7f5d3df05bae3 100644 (file)
@@ -1106,7 +1106,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                  || r->howto->pc_relative
                  || r->howto->bitpos != 0
                  || r->howto->dst_mask != 0xffffffff
-                 || octets + 4 > stabsize)
+                 || octets > stabsize - 4)
                {
                  _bfd_error_handler
                    (_("unsupported .stab relocation"));