]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/orangefs: use snprintf() instead of sprintf()
authorAmir Mohammad Jahangirzad <a.jahangirzad@gmail.com>
Sun, 8 Jun 2025 16:35:59 +0000 (20:05 +0330)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:59 +0000 (16:25 +0200)
commit3799bec649b698aead6b2106160fd23ca3168a4e
tree62c11c5e1ca6159295267578ca52451f7bde98d1
parenta145c269dc5380c063a20a0db7e6df2995962e9d
fs/orangefs: use snprintf() instead of sprintf()

[ Upstream commit cdfa1304657d6f23be8fd2bb0516380a3c89034e ]

sprintf() is discouraged for use with bounded destination buffers
as it does not prevent buffer overflows when the formatted output
exceeds the destination buffer size. snprintf() is a safer
alternative as it limits the number of bytes written and ensures
NUL-termination.

Replace sprintf() with snprintf() for copying the debug string
into a temporary buffer, using ORANGEFS_MAX_DEBUG_STRING_LEN as
the maximum size to ensure safe formatting and prevent memory
corruption in edge cases.

EDIT: After this patch sat on linux-next for a few days, Dan
Carpenter saw it and suggested that I use scnprintf instead of
snprintf. I made the change and retested.

Signed-off-by: Amir Mohammad Jahangirzad <a.jahangirzad@gmail.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/orangefs/orangefs-debugfs.c