]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/nouveau: replace snprintf() with scnprintf() in nvkm_snprintbf()
authorSeyediman Seyedarab <imandevel@gmail.com>
Thu, 24 Jul 2025 19:59:13 +0000 (15:59 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:08 +0000 (12:45 +0100)
commitdd7e0326b77af7ff7493c1decb6040bab0673a12
tree759263a09ac1c8cb48a9e4e2677b7d7fcf16d3d8
parente29ee40c2e6ea43e8818deb52ba04ce96989d555
drm/nouveau: replace snprintf() with scnprintf() in nvkm_snprintbf()

[ Upstream commit 6510b62fe9303aaf48ff136ff69186bcfc32172d ]

snprintf() returns the number of characters that *would* have been
written, which can overestimate how much you actually wrote to the
buffer in case of truncation. That leads to 'data += this' advancing
the pointer past the end of the buffer and size going negative.

Switching to scnprintf() prevents potential buffer overflows and ensures
consistent behavior when building the output string.

Signed-off-by: Seyediman Seyedarab <ImanDevel@gmail.com>
Link: https://lore.kernel.org/r/20250724195913.60742-1-ImanDevel@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/nouveau/nvkm/core/enum.c