From: Tom Tromey <tom@tromey.com>
To: Stephan Rohr <stephan.rohr@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix overflow caused by value_print_array_elements
Date: Mon, 19 Oct 2026 11:40:48 -0600 [thread overview]
Message-ID: <87jynd1tcv.fsf@tromey.com> (raw)
In-Reply-To: <20261015094703.112063-1-stephan.rohr@intel.com> (Stephan Rohr's message of "Thu, 15 Oct 2026 09:47:03 +0000")
>>>>> Stephan Rohr <stephan.rohr@intel.com> writes:
Thanks for the patch.
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> When printing an array whose stride is larger than its element type,
> GDB allocates memory for each array element based on the element's
> true type. The allocated buffer may include some padding.
> "value_print_array_elements ()" passes the stride as the bit length to
> "from_component_bitsize ()". This is silently swallowed if the stride
> does not exceed the size of the allocated buffer but corrupts the heap
> if the write goes beyond. Pass the size of the element's true type
> ^instead.
Stray "^" here.
> +
> + /* For packed arrays, the stride may be smaller than the element's target
> + type. */
> + ULONGEST elt_bits = std::min (bit_stride,
> + 8 * check_typedef (elttype)->length ());
I think it would be good if the test case included a case where the
stride is smaller than the element's type. I think currently it only
tests the case where the element type is smaller than the stride.
Tom
prev parent reply other threads:[~2026-10-19 17:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 9:47 Stephan Rohr
2026-10-19 17:40 ` Tom Tromey [this message]
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=87jynd1tcv.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=stephan.rohr@intel.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