From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
krisman@collabora.com, jirislaby@kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>, stable@vger.kernel.org
Subject: [PATCH v2] unicode: don't write -1 after NUL terminator
Date: Thu, 3 Nov 2022 12:30:21 +0100 [thread overview]
Message-ID: <20221103113021.3271-1-Jason@zx2c4.com> (raw)
In-Reply-To: <79db9616-a2ee-9a1a-9a35-b82f65b6d15e@kernel.org>
If the intention is to overwrite the first NUL with a -1, s[strlen(s)]
is the first NUL, not s[strlen(s)+1].
Cc: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
fs/unicode/mkutf8data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/unicode/mkutf8data.c b/fs/unicode/mkutf8data.c
index bc1a7c8b5c8d..61800e0d3226 100644
--- a/fs/unicode/mkutf8data.c
+++ b/fs/unicode/mkutf8data.c
@@ -3194,7 +3194,7 @@ static int normalize_line(struct tree *tree)
/* Second test: length-limited string. */
s = buf2;
/* Replace NUL with a value that will cause an error if seen. */
- s[strlen(s) + 1] = -1;
+ s[strlen(s)] = -1;
t = buf3;
if (utf8cursor(&u8c, tree, s))
return -1;
--
2.38.1
next prev parent reply other threads:[~2022-11-03 11:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 1:24 [PATCH] unicode: don't write -1 after NULL terminator Jason A. Donenfeld
2022-11-03 7:00 ` Jiri Slaby
2022-11-03 11:30 ` Jason A. Donenfeld [this message]
2022-11-07 14:45 ` [PATCH v2] unicode: don't write -1 after NUL terminator Gabriel Krisman Bertazi
2022-11-07 15:09 ` Jason A. Donenfeld
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=20221103113021.3271-1-Jason@zx2c4.com \
--to=jason@zx2c4.com \
--cc=jirislaby@kernel.org \
--cc=krisman@collabora.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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