From: Pedro Alves <pedro@palves.net>
To: Luis Machado <luis.machado@amd.com>, gdb-patches@sourceware.org
Cc: guinevere@redhat.com
Subject: Re: [PATCH v2] gdb: replace alloca with gdb::unique_xmalloc_ptr in remote-fileio.c
Date: Wed, 1 Jul 2026 19:20:19 +0100 [thread overview]
Message-ID: <f80fb381-ffb9-488b-903a-4b291ecd4ffc@palves.net> (raw)
In-Reply-To: <20260701150714.3124191-1-luis.machado@amd.com>
On 2026-07-01 16:07, Luis Machado wrote:
> char *c;
> LONGEST retlong;
> @@ -211,6 +213,11 @@ remote_fileio_extract_ptr_w_len (char **buf, CORE_ADDR *ptrval, int *length)
> *buf = c;
> if (remote_fileio_extract_long (buf, &retlong))
> return -1;
> + /* Reject negative lengths and zero (unless the caller permits it for the
> + Fsystem NULL-cmdline sentinel). Oversized names are caught by the
> + syscall. */
> + if (retlong < 0 || (!allow_zero_length && retlong == 0))
> + return -1;
Given this no longer limits on PATH_MAX, RETLONG can be higher than INT_MAX
and still positive, and then the cast below yields bad values:
> *length = (int) retlong;
Like, e.g., (int) 0x80000000, wraps to INT_MIN (a negative length).
So we should limit on INT_MAX.
> + /* Valid: largest positive length accepted (technically INT_MAX). */
> + SELF_CHECK (parse ("1/7fffffff") == 0);
> + SELF_CHECK (length == 0x7fffffff);
This test would have caught it, I think:
SELF_CHECK (parse ("1/80000000") == -1);
next prev parent reply other threads:[~2026-07-01 18:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 9:52 [PATCH] gdb: replace alloca with gdb::char_vector " Luis Machado
2026-06-30 21:07 ` Guinevere Larsen
2026-07-01 13:03 ` Pedro Alves
2026-07-01 15:08 ` Machado, Luis
2026-07-01 15:07 ` [PATCH v2] gdb: replace alloca with gdb::unique_xmalloc_ptr " Luis Machado
2026-07-01 18:20 ` Pedro Alves [this message]
2026-07-01 19:01 ` Machado, Luis
2026-07-01 19:01 ` [PATCH v3] " Luis Machado
2026-07-01 19:08 ` Pedro Alves
2026-07-03 8:35 ` Luis
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=f80fb381-ffb9-488b-903a-4b291ecd4ffc@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
--cc=luis.machado@amd.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