From: Nishant Kumar Singh Date: Fri, 10 Apr 2026 02:58:12 +0000 (+0000) Subject: aplay: use snprintf instead of sprintf in device_list() X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;p=alsa-utils.git aplay: use snprintf instead of sprintf in device_list() sprintf() does not perform bounds checking. Replace it with snprintf() using sizeof(name) to follow safer coding practices and make the buffer size explicit, consistent with how similar fixes have been applied elsewhere in the codebase Signed-off-by: Nishant Kumar Singh Signed-off-by: Takashi Iwai --- diff --git a/aplay/aplay.c b/aplay/aplay.c index 0050032..74ec947 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -283,7 +283,7 @@ static void device_list(void) snd_pcm_stream_name(stream)); while (card >= 0) { char name[32]; - sprintf(name, "hw:%d", card); + snprintf(name, sizeof(name), "hw:%d", card); if ((err = snd_ctl_open(&handle, name, 0)) < 0) { error("control open (%i): %s", card, snd_strerror(err)); goto next_card;