]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: use snprintf instead of sprintf in device_list() HEAD master
authorNishant Kumar Singh <nishantsingh2jan1998@gmail.com>
Fri, 10 Apr 2026 02:58:12 +0000 (02:58 +0000)
committerTakashi Iwai <tiwai@suse.de>
Sat, 11 Apr 2026 08:08:52 +0000 (10:08 +0200)
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 <nishantsingh2jan1998@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay/aplay.c

index 0050032dfcebb38afcc808af362535b45c02e8cb..74ec94789599ce67aae75921b86a6cab7e6dfd3d 100644 (file)
@@ -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;