From: Quentin Schulz <quentin.schulz@cherry.de>
To: Aristo Chen <aristo.chen@canonical.com>, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Rasmus Villemoes <ravi@prevas.dk>, Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v1 1/2] tools: mkimage: fix get_basename crash on paths with dotted directories
Date: Thu, 21 May 2026 11:12:34 +0200 [thread overview]
Message-ID: <6e64c6df-e66f-45e2-9214-baa02df9bc1c@cherry.de> (raw)
In-Reply-To: <20260521023503.29315-1-aristo.chen@canonical.com>
Hi Aristo,
On 5/21/26 4:34 AM, Aristo Chen wrote:
> The get_basename() helper in tools/fit_image.c searches the entire input
> path for the last '/' and the last '.' independently. When the last '.'
> falls at an offset earlier than the last '/' (for example "./mydt",
> "a.b/c", or "sub.d/leaf"), 'end' points before 'start' and the computed
> length is negative. The subsequent size check uses signed comparison so
> the negative value passes through unchanged, and memcpy() is then called
> with that length implicitly cast to size_t, which segfaults.
>
> Restrict the dot search to the substring that follows the last slash so
> that only an extension in the filename component can become the end of
> the basename. This matches the function's stated intent of stripping an
> extension from the leaf, and keeps the existing behaviour for typical
> inputs such as "arch/arm/dts/foo.dtb".
>
> Reproducer that previously segfaulted and now produces a valid image:
>
> echo dummy > kernel.bin
> echo dummy > ./mydt
> ./tools/mkimage -f auto -A arm -O linux -T kernel -C none \
> -a 0x80000000 -e 0x80000000 -n test \
> -d kernel.bin -b ./mydt out.itb
>
> Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Thanks!
Quentin
next prev parent reply other threads:[~2026-05-21 9:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 2:34 [PATCH v1 1/2] tools: mkimage: fix get_basename crash on paths with dotted directories Aristo Chen
2026-05-21 2:35 ` [PATCH v1 2/2] test/py: cover " Aristo Chen
2026-05-21 9:10 ` Quentin Schulz
2026-05-21 15:59 ` Aristo Chen
2026-05-21 9:12 ` Quentin Schulz [this message]
2026-05-21 16:09 ` [PATCH v1 1/2] tools: mkimage: fix " Marek Vasut
2026-05-21 16:12 ` Quentin Schulz
2026-05-21 16:17 ` Marek Vasut
2026-05-22 3:07 ` Aristo Chen
2026-05-26 7:03 ` [PATCH v2 0/2] " Aristo Chen
2026-05-26 7:03 ` [PATCH v2 1/2] " Aristo Chen
2026-05-26 7:03 ` [PATCH v2 2/2] test/py: cover " Aristo Chen
2026-06-12 1:59 ` [PATCH v2 0/2] tools: mkimage: fix " Tom Rini
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=6e64c6df-e66f-45e2-9214-baa02df9bc1c@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=aristo.chen@canonical.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=ravi@prevas.dk \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.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