mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
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>
This commit is contained in:
parent
e29ee40c2e
commit
dd7e0326b7
1 changed files with 1 additions and 1 deletions
|
|
@ -44,7 +44,7 @@ nvkm_snprintbf(char *data, int size, const struct nvkm_bitfield *bf, u32 value)
|
|||
bool space = false;
|
||||
while (size >= 1 && bf->name) {
|
||||
if (value & bf->mask) {
|
||||
int this = snprintf(data, size, "%s%s",
|
||||
int this = scnprintf(data, size, "%s%s",
|
||||
space ? " " : "", bf->name);
|
||||
size -= this;
|
||||
data += this;
|
||||
|
|
|
|||
Loading…
Reference in a new issue