From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>
Cc: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH/committed] sim: rl78: clean up various warnings
Date: Wed, 5 May 2021 14:52:58 -0400 [thread overview]
Message-ID: <YJLpihiwWrxtrjFv@vapier> (raw)
In-Reply-To: <87k0odqe9w.fsf@tromey.com>
On 05 May 2021 11:30, Tom Tromey wrote:
> >>>>> "Mike" == Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Mike> Fix a logic error when processing commands where p was reassigned
> Mike> to cmd and then has its leading whitespace scanned a 2nd time.
> Mike> Handle short reads with fread().
>
> Mike> - /* Find the extent of the command word. */
> Mike> - for (p = cmd; *p; p++)
> Mike> - if (isspace (*p))
> Mike> - break;
> Mike> -
>
> I'm not sure it makes sense to completely delete this.
> Perhaps instead just removing 'p = cmd' is correct?
>
> It looks to me that this code is trying to parse a command name followed
> by arguments. Like, ideally, "monitor trace on" should set cmd="trace"
> and args="on", but with the patch I don't think this will happen.
you're right that the code is more subtle than i thought. but it's still
broken with that tweak. it's broken today too. pretty sure this code has
always been wrong and crashes, either from writing to read-only memory, or
trying to free an invalid pointer. it basically needs to be gutted.
glancing at some other ports (m32c & rx), they have the same bugs, so looks
like it started with one bad form, and then copied around.
i think replacing it with buildargv is easiest.
-mike
next prev parent reply other threads:[~2021-05-05 18:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 3:04 Mike Frysinger via Gdb-patches
2021-05-05 17:30 ` Tom Tromey
2021-05-05 18:52 ` Mike Frysinger via Gdb-patches [this message]
2021-05-05 19:05 ` Tom Tromey
2021-05-05 19:02 ` [PATCH] sim: m32c/rl78/rx: fix command parsing Mike Frysinger via Gdb-patches
2021-05-05 19:13 ` Tom Tromey
2021-05-05 23:03 ` [PATCH v2] " Mike Frysinger via Gdb-patches
2021-05-05 23:06 ` [PATCH v3] " Mike Frysinger via Gdb-patches
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=YJLpihiwWrxtrjFv@vapier \
--to=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
--cc=vapier@gentoo.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