Skip to content

Commit 1eb123c

Browse files
tiwaibroonie
authored andcommitted
ASoC: SOF: debug: Fix potential buffer overflow by snprintf()
snprintf() returns the would-be-filled size when the string overflows the given buffer size, hence using this value may result in the buffer overflow (although it's unrealistic). This patch replaces with a safer version, scnprintf() for papering over such a potential issue. Fixes: 5b10b62 ("ASoC: SOF: Add `memory_info` file to debugfs") Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ca3b7b9 commit 1eb123c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sound/soc/sof/debug.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ static int memory_info_update(struct snd_sof_dev *sdev, char *buf, size_t buff_s
252252
}
253253

254254
for (i = 0, len = 0; i < reply->num_elems; i++) {
255-
ret = snprintf(buf + len, buff_size - len, "zone %d.%d used %#8x free %#8x\n",
256-
reply->elems[i].zone, reply->elems[i].id,
257-
reply->elems[i].used, reply->elems[i].free);
255+
ret = scnprintf(buf + len, buff_size - len, "zone %d.%d used %#8x free %#8x\n",
256+
reply->elems[i].zone, reply->elems[i].id,
257+
reply->elems[i].used, reply->elems[i].free);
258258
if (ret < 0)
259259
goto error;
260260
len += ret;

0 commit comments

Comments
 (0)