Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb-17-branch, gdb/stabs] Fix out-of-bounds write in read_member_functions
Date: Wed, 2 Sep 2026 08:57:24 -0400	[thread overview]
Message-ID: <b1119966-7aee-4e3d-a7a7-01c9566fd9ef@simark.ca> (raw)
In-Reply-To: <20260902090544.2061258-1-tdevries@suse.de>



On 2026-09-02 05:05, Tom de Vries wrote:
>  gdb/stabsread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/stabsread.c b/gdb/stabsread.c
> index 2d1411e9146..6cc3c5c7e02 100644
> --- a/gdb/stabsread.c
> +++ b/gdb/stabsread.c
> @@ -5112,6 +5112,7 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
>  		{
>  		  if (!is_destructor_name (tmp_sublist->fn_field.physname))
>  		    {
> +		      last_sublist = tmp_sublist;
>  		      tmp_sublist = tmp_sublist->next;
>  		      continue;
>  		    }
> @@ -5122,7 +5123,6 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
>  		    last_sublist->next = tmp_sublist->next;
>  		  else
>  		    sublist = tmp_sublist->next;
> -		  last_sublist = tmp_sublist;
>  		  tmp_sublist = tmp_sublist->next;
>  		}

LGTM.  last_sublist is meant to point to the last non-destructor
(non-filtetered-out) node.  The line you remove makes it point to a
destructor node, clearly wrong.

If this was for code in master, I would propose adding some comments,
like:

		  /* Unlink the destructor.  */
		  if (last_sublist)
		    {
		      /* Destructor is not the first element in linked list,
			 change preceding element's next to point to following
			 element.  */
		      last_sublist->next = tmp_sublist->next;
		    }
		  else
		    {
		      /* Destructor is the first element in linked list,
			 change head (SUBLIST) to point to following
			 element.  */
		      sublist = tmp_sublist->next;
		    }

(I wrote these comments locally to make sure I understood the code)

And also rename last_sublist to last_non_destructor_sublist.  And also
switch all this to not use a hand-crafted linked list.  But given that
this is for code on its way out, the two-liner fix is fine.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

  reply	other threads:[~2026-09-02 12:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  9:05 Tom de Vries
2026-09-02 12:57 ` Simon Marchi [this message]
2026-09-09 13:10   ` Tom de Vries

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=b1119966-7aee-4e3d-a7a7-01c9566fd9ef@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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