From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>, hch@lst.de
Subject: [PATCH] xfs_scrub: fix buffer overflow in string_escape
Date: Thu, 20 Feb 2025 14:07:58 -0800 [thread overview]
Message-ID: <20250220220758.GT21808@frogsfrogsfrogs> (raw)
From: Darrick J. Wong <djwong@kernel.org>
Need to allocate one more byte for the null terminator, just in case the
/entire/ input string consists of non-printable bytes e.g. emoji.
Cc: <linux-xfs@vger.kernel.org> # v4.15.0
Fixes: 396cd0223598bb ("xfs_scrub: warn about suspicious characters in directory/xattr names")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
scrub/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scrub/common.c b/scrub/common.c
index 6eb3c026dc5ac9..7ea0277bc511ce 100644
--- a/scrub/common.c
+++ b/scrub/common.c
@@ -320,7 +320,7 @@ string_escape(
char *q;
int x;
- str = malloc(strlen(in) * 4);
+ str = malloc((strlen(in) * 4) + 1);
if (!str)
return NULL;
for (p = in, q = str; *p != '\0'; p++) {
next reply other threads:[~2025-02-20 22:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 22:07 Darrick J. Wong [this message]
2025-02-20 22:10 ` [RFC PATCH] generic/45[34]: add colored emoji variants to unicode tests Darrick J. Wong
2025-02-24 14:34 ` Christoph Hellwig
2025-02-24 8:36 ` [PATCH] xfs_scrub: fix buffer overflow in string_escape Andrey Albershteyn
2025-02-24 14:11 ` Christoph Hellwig
2025-02-24 17:54 ` Darrick J. Wong
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=20250220220758.GT21808@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=hch@lst.de \
--cc=linux-xfs@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