public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_scrub: fix buffer overflow in string_escape
@ 2025-02-20 22:07 Darrick J. Wong
  2025-02-20 22:10 ` [RFC PATCH] generic/45[34]: add colored emoji variants to unicode tests Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Darrick J. Wong @ 2025-02-20 22:07 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: xfs, hch

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++) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-24 17:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 22:07 [PATCH] xfs_scrub: fix buffer overflow in string_escape Darrick J. Wong
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox