* vms-lib.c (vms_traverse_index): Sanity check size remaining
before accessing vms_idx or vms_elfidx.
+2020-08-03 Alan Modra <amodra@gmail.com>
+
+ * vms-lib.c (vms_traverse_index): Sanity check size remaining
+ before accessing vms_idx or vms_elfidx.
+
2020-08-03 Alan Modra <amodra@gmail.com>
PR 26330
unsigned int flags;
/* Extract key length. */
- if (bfd_libdata (abfd)->ver == LBR_MAJORID)
+ if (bfd_libdata (abfd)->ver == LBR_MAJORID
+ && offsetof (struct vms_idx, keyname) <= (size_t) (endp - p))
{
struct vms_idx *ridx = (struct vms_idx *)p;
flags = 0;
keyname = ridx->keyname;
}
- else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID)
+ else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID
+ && offsetof (struct vms_elfidx, keyname) <= (size_t) (endp - p))
{
struct vms_elfidx *ridx = (struct vms_elfidx *)p;