summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-11-19 14:52:17 +0100
committerTakashi Iwai <tiwai@suse.de>2025-11-19 17:16:49 +0100
commitad5f82ab04bcad56de85723bdd48e44b70a16948 (patch)
treebe90e90c79fa5d3de700d36d0c887f0a616ad6a0 /sound
parent18a4895370a79a3efb4a53ccd1efffef6c5b634e (diff)
ALSA: pcmtest: Replace deprecated strcpy with strscpy_pad in setup_patt_bufs
strcpy() has been deprecated [1] because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. Replace it with the safer strscpy_pad(), and use kmalloc() instead of kzalloc() because strscpy_pad() zero-pads the destination buffer and therefore avoids writing to it twice. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1] Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://patch.msgid.link/20251119135217.233084-1-thorsten.blum@linux.dev Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/drivers/pcmtest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c
index 19b3f306c564..b8474631f0b5 100644
--- a/sound/drivers/pcmtest.c
+++ b/sound/drivers/pcmtest.c
@@ -696,10 +696,10 @@ static int setup_patt_bufs(void)
size_t i;
for (i = 0; i < ARRAY_SIZE(patt_bufs); i++) {
- patt_bufs[i].buf = kzalloc(MAX_PATTERN_LEN, GFP_KERNEL);
+ patt_bufs[i].buf = kmalloc(MAX_PATTERN_LEN, GFP_KERNEL);
if (!patt_bufs[i].buf)
break;
- strcpy(patt_bufs[i].buf, DEFAULT_PATTERN);
+ strscpy_pad(patt_bufs[i].buf, DEFAULT_PATTERN, MAX_PATTERN_LEN);
patt_bufs[i].len = DEFAULT_PATTERN_LEN;
}