From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Kyle Zeng <kylebot@openai.com>, <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <outbounddisclosures@openai.com>
Subject: Re: [PATCH] fs/ntfs3: reserve NUL byte when converting UTF-16 names
Date: Thu, 23 Jul 2026 16:27:00 +0200 [thread overview]
Message-ID: <4bdf2d9d-a0c9-40d0-b130-2be6e1beb5ec@paragon-software.com> (raw)
In-Reply-To: <20260611213331.16763-1-kylebot@openai.com>
On 6/11/26 23:33, Kyle Zeng wrote:
> ntfs_utf16_to_nls() appends a trailing NUL to the converted output,
> but it passes the caller-supplied size directly to the conversion loop.
> For the UTF-8 path, utf16s_to_utf8s() can legitimately fill all
> buf_len bytes and return buf_len, after which ntfs_utf16_to_nls()
> writes the terminator one byte past the end of the destination buffer.
>
> The same contract problem exists for the NLS path when a converted
> character consumes the last available byte.
>
> Reserve one byte for the terminator before doing either conversion.
> The function continues to return the number of converted bytes,
> excluding the NUL terminator.
>
> Assisted-by: Codex:gpt-5.5
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
> ---
> fs/ntfs3/dir.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c
> index d99ab086ef6f..e8892cd94e04 100644
> --- a/fs/ntfs3/dir.c
> +++ b/fs/ntfs3/dir.c
> @@ -25,6 +25,11 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
>
> static_assert(sizeof(wchar_t) == sizeof(__le16));
>
> + if (buf_len <= 0)
> + return -EINVAL;
> +
> + buf_len -= 1;
> +
> if (!nls) {
> /* UTF-16 -> UTF-8 */
> ret = utf16s_to_utf8s((wchar_t *)name, len, UTF16_LITTLE_ENDIAN,
> --
> 2.43.0
>
Hello,
Sorry for the delay.
Your patch was applied, thank you.
Regards,
Konstantin
prev parent reply other threads:[~2026-07-23 14:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 21:33 Kyle Zeng
2026-06-21 0:46 ` XIAO WU
2026-07-23 14:27 ` Konstantin Komarov [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=4bdf2d9d-a0c9-40d0-b130-2be6e1beb5ec@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=kylebot@openai.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=outbounddisclosures@openai.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
all inboxes | Powered by JetHome®