From: Gary Benson <gbenson@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix buffer overrun found by Coverity
Date: Mon, 08 Oct 2018 16:34:00 -0000 [thread overview]
Message-ID: <20181008163422.GA8415@blade.nx> (raw)
In-Reply-To: <87o9c8h3y9.fsf@tromey.com>
Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
>
> Gary> I would have committed this as obvious, but the testsuite
> Gary> doesn't exercise this piece of code; I can't realistically
> Gary> say I've regression tested this change, so I'd like another
> Gary> pair of eyes on it to be sure.
>
> What about the fission-dwp.exp board maybe?
> Or one of the other boards.
Oh, good call, it does.
> Gary> - memset (ids, 255, (DW_SECT_MAX + 1) * sizeof (int32_t));
> Gary> - memset (ids_seen, 255, (DW_SECT_MAX + 1) * sizeof (int32_t));
> Gary> + memset (ids, 255, sizeof_ids);
> Gary> + memset (ids_seen, 255, sizeof (ids_seen));
>
> Later the code does this:
>
> if (id < DW_SECT_MIN || id > DW_SECT_MAX)
> {
> error (_("Dwarf Error: bad DWP hash table, bad section id %d"
> [...]
> ids_seen[id] = i;
> ids[i] = id;
>
> So I think it would be good to ensure that MAX_NR_V2_DWO_SECTIONS is
> >= DW_SECT_MAX + 1. At least if I'm understanding this properly.
I don't *think* it's necessary:
ids_seen is indexed by "id",
which is 1 <= id <= DW_SECT_MAX;
ids is indexed by "i",
which is 0 <= i < nr_columns,
and nr_columns is nr_columns <= MAX_NR_V2_DWO_SECTIONS,
so 0 <= i < MAX_NR_V2_DWO_SECTIONS.
i.e. the dimensions are right, it's just the memset which isn't.
I think!
Ok, so this one's built and regtested on RHEL 7.5 x86_64 now, with
the fission-dwp.exp board. Assuming the dimensions thing above is
correct, is this ok to commit?
Cheers,
Gary
next prev parent reply other threads:[~2018-10-08 16:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 13:53 Gary Benson
2018-10-05 14:18 ` Tom Tromey
2018-10-08 16:34 ` Gary Benson [this message]
2018-10-08 17:41 ` Tom Tromey
2018-10-09 13:25 ` Gary Benson
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=20181008163422.GA8415@blade.nx \
--to=gbenson@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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).