From: Alan Modra <amodra@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] Re: Fix address violations when reading corrupt VMS records
Date: Thu, 18 Apr 2024 01:02:37 +0000 (GMT) [thread overview]
Message-ID: <20240418010237.A40AB384AB66@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ebf18671351d94185823d364b75369abc1baba31
commit ebf18671351d94185823d364b75369abc1baba31
Author: Alan Modra <amodra@gmail.com>
Date: Wed Apr 17 22:28:23 2024 +0930
Re: Fix address violations when reading corrupt VMS records
Fixes error reports about the length of EEOM records produced by gas.
PR 21618
* vms-alpha.c (evax_bfd_print_emh): Don't read subtyp if short
record. Consolidate error messages.
(evax_bfd_print_eeom): Allow length 10 record.
Diff:
---
bfd/vms-alpha.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 8b5e3c21ac6..404638cf3d9 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -6110,20 +6110,23 @@ static void
evax_bfd_print_emh (FILE *file, unsigned char *rec, unsigned int rec_len)
{
struct vms_emh_common *emh = (struct vms_emh_common *)rec;
- unsigned int subtype;
+ int subtype = -1;
int extra;
- subtype = (unsigned) bfd_getl16 (emh->subtyp);
+ if (rec_len >= sizeof (*emh))
+ subtype = bfd_getl16 (emh->subtyp);
/* xgettext:c-format */
- fprintf (file, _(" EMH %u (len=%u): "), subtype, rec_len);
+ fprintf (file, _(" EMH %d (len=%u): "), subtype, rec_len);
/* PR 21618: Check for invalid lengths. */
- if (rec_len < sizeof (* emh))
+ if (rec_len < sizeof (*emh))
{
- fprintf (file, _(" Error: The length is less than the length of an EMH record\n"));
+ fprintf (file, _(" Error: %s min length is %u\n"),
+ "EMH", (unsigned) sizeof (*emh));
return;
}
+
extra = rec_len - sizeof (struct vms_emh_common);
switch (subtype)
@@ -6138,7 +6141,8 @@ evax_bfd_print_emh (FILE *file, unsigned char *rec, unsigned int rec_len)
/* PR 21840: Check for invalid lengths. */
if (rec_len < sizeof (* mhd))
{
- fprintf (file, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
+ fprintf (file, _(" Error: %s min length is %u\n"),
+ "EMH_MHD", (unsigned) sizeof (*mhd));
return;
}
fprintf (file, _("Module header\n"));
@@ -6214,9 +6218,10 @@ evax_bfd_print_eeom (FILE *file, unsigned char *rec, unsigned int rec_len)
fprintf (file, _(" EEOM (len=%u):\n"), rec_len);
/* PR 21618: Check for invalid lengths. */
- if (rec_len < sizeof (* eeom))
+ if (rec_len < 10)
{
- fprintf (file, _(" Error: The length is less than the length of an EEOM record\n"));
+ fprintf (file, _(" Error: %s min length is %u\n"),
+ "EEOM", 10);
return;
}
@@ -6224,7 +6229,8 @@ evax_bfd_print_eeom (FILE *file, unsigned char *rec, unsigned int rec_len)
(unsigned)bfd_getl32 (eeom->total_lps));
fprintf (file, _(" completion code: %u\n"),
(unsigned)bfd_getl16 (eeom->comcod));
- if (rec_len > 10)
+
+ if (rec_len >= sizeof (*eeom))
{
fprintf (file, _(" transfer addr flags: 0x%02x\n"), eeom->tfrflg);
fprintf (file, _(" transfer addr psect: %u\n"),
reply other threads:[~2024-04-18 1:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240418010237.A40AB384AB66@sourceware.org \
--to=amodra@sourceware.org \
--cc=binutils-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).