All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Husemann <martin@NetBSD.org>
To: Andrew Goodbody <andrew.goodbody@linaro.org>
Cc: Tom Rini <trini@konsulko.com>, u-boot@lists.denx.de
Subject: Re: [PATCH] fs: fat: Prevent possible buffer overflow
Date: Thu, 17 Jul 2025 18:57:50 +0200	[thread overview]
Message-ID: <20250717165749.GE20410@mail.duskware.de> (raw)
In-Reply-To: <1e80ff96-48a5-4a17-85df-59c8459b3083@linaro.org>

On Thu, Jul 17, 2025 at 04:38:50PM +0100, Andrew Goodbody wrote:
> The original use of strcpy suggests that the string must be \0 terminated. I
> will admit that I do not know the code well, is dir->itr.name guaranteed to
> be a known fixed size?

You are right, the iterator's name pointer always points to a \0 terminated
string, but also always points to one shorter than FS_DIRENT_NAME_LEN.

The on-disk fields are not \0 terminated, but the code extracting them
deals with it properly. If the length would overflow, a NULL instead
of a dir_entry * is returned, so while it is not obvious, AFAICT the
original code is fine.

Martin

  reply	other threads:[~2025-07-17 16:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 14:54 [PATCH] fs: fat: Prevent possible buffer overflow Andrew Goodbody
2025-07-17 14:58 ` Martin Husemann
2025-07-17 15:38   ` Andrew Goodbody
2025-07-17 16:57     ` Martin Husemann [this message]
2025-07-18  9:17       ` Andrew Goodbody

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=20250717165749.GE20410@mail.duskware.de \
    --to=martin@netbsd.org \
    --cc=andrew.goodbody@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.