asan: segv in parse_module
authorAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 11:13:54 +0000 (21:43 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 4 Jan 2023 13:22:26 +0000 (23:52 +1030)
* vms-alpha.c (parse_module): Ignore DST__K_SRC_SETFILE data
if out of range.

bfd/vms-alpha.c

index a9f87962f5b63ceac5b3ee0d2f6ec37a24afb1f6..fd2cf50441f9eaf8d25001abb0f406fc27389b41 100644 (file)
@@ -4577,8 +4577,11 @@ parse_module (bfd *abfd, struct module *module, unsigned char *ptr,
 
                case DST__K_SRC_SETFILE:
                  data = bfd_getl16 (src_ptr + DST_S_W_SRC_UNSWORD);
-                 curr_srec->sfile = data;
-                 curr_srec->srec = module->file_table[data].srec;
+                 if ((unsigned int) data < module->file_table_count)
+                   {
+                     curr_srec->sfile = data;
+                     curr_srec->srec = module->file_table[data].srec;
+                   }
                  vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data));
                  break;