Fix another memory access error triggered by attempting to parse a corrupt binary.
authorNick Clifton <nickc@redhat.com>
Mon, 24 Jul 2017 13:04:04 +0000 (14:04 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 24 Jul 2017 13:04:04 +0000 (14:04 +0100)
PR 21813
(alpha_vms_object_p): Check for a truncated record.

bfd/ChangeLog
bfd/vms-alpha.c

index a854a1266e1c1afa81ed40259c7504a6145e6a58..9ae5da99ebe43f545a0ab359d2f0adbfe0144afc 100644 (file)
@@ -22,6 +22,8 @@
        (image_set_ptr): Likewise.
        (alpha_vms_slurp_relocs): Likewise.
 
+       (alpha_vms_object_p): Check for a truncated record.
+
 2017-07-24  Nick Clifton  <nickc@redhat.com>
 
        PR 21803
index 5e9170d7b1be9e9213685bdf372d718f86e77ea7..610b034ccd026224b66972c7174c1fb25aade794 100644 (file)
@@ -2679,6 +2679,9 @@ alpha_vms_object_p (bfd *abfd)
           PRIV (recrd.buf_size) = PRIV (recrd.rec_size);
         }
 
+      /* PR 21813: Check for a truncated record.  */
+      if (PRIV (recrd.rec_size < test_len))
+       goto error_ret;
       /* Read the remaining record.  */
       remaining = PRIV (recrd.rec_size) - test_len;
       to_read = MIN (VMS_BLOCK_SIZE - test_len, remaining);