Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb] Fix heap-buffer-overflow in args_complete_p
Date: Tue, 6 Jan 2026 15:51:40 +0100	[thread overview]
Message-ID: <66de7dbf-d8d4-489f-b2e6-16ed252ffedc@suse.de> (raw)
In-Reply-To: <87jyxwxbdo.fsf@tromey.com>

On 1/5/26 5:38 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> +  auto at = [&] (const char *s)
> Tom> +    {
> Tom> +      return s > end ? '\0' : *s;
> Tom> +    };
> 
> I think it would better to avoid stepping off the end at the points
> where the pointer is incremented.
> 
> Tom> +  while (at (input) != '\0')
> 
> Like this could be
> 
>     for (input = skip_spaces (input); *input != '\0'; input = skip_spaces (input))
> 
> and then there's like one or two spots to check in the loop.

I've submitted a v2 ( 
https://sourceware.org/pipermail/gdb-patches/2026-January/223715.html ). 
  I didn't do the transformation you suggested here, I tried to do 
something minimal.

I could submit a follow-up patch to do some refactoring in this 
function, though I'd likely do something like:
...
       while (true)
         {
           input = skip_spaces (input);
           if (*input == '\0')
              break;
...
instead of the for loop you're suggesting.

Thanks,
- Tom

  reply	other threads:[~2026-01-06 14:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-03 14:55 Tom de Vries
2026-01-05 16:38 ` Tom Tromey
2026-01-06 14:51   ` Tom de Vries [this message]
2026-01-05 19:57 ` Andrew Burgess
2026-01-05 20:02   ` Andrew Burgess
2026-01-05 20:09   ` Tom Tromey
2026-01-06  8:47   ` Tom de Vries
2026-01-06  9:29     ` Tom de Vries
2026-01-06 14:53     ` Tom de Vries
2026-01-07 10:46     ` Andrew Burgess
2026-01-07 11:21       ` Tom de Vries
2026-01-07 15:01         ` Andrew Burgess
2026-01-07 18:13           ` Tom Tromey
2026-01-12 11:42             ` Andrew Burgess

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=66de7dbf-d8d4-489f-b2e6-16ed252ffedc@suse.de \
    --to=tdevries@suse.de \
    --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