OSDN Git Service

staging: most: sound: replace snprintf with strscpy
authorColin Ian King <colin.king@canonical.com>
Tue, 18 Dec 2018 11:35:52 +0000 (11:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Dec 2018 07:28:22 +0000 (08:28 +0100)
Using snprintf without a format specifier is potentially risky if
the string device_name contains format specifiers. Replace this with
the safer and more efficient strscpy.

Cleans up clang warning:
drivers/staging/most/sound/sound.c:673:41: warning: format string is not
a string literal (potentially insecure) [-Wformat-security]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/sound/sound.c

index 29a4c72..79ab3a7 100644 (file)
@@ -670,7 +670,7 @@ skip_adpt_alloc:
                goto err_free_adpt;
 
        pcm->private_data = channel;
-       snprintf(pcm->name, sizeof(pcm->name), device_name);
+       strscpy(pcm->name, device_name, sizeof(pcm->name));
        snd_pcm_set_ops(pcm, direction, &pcm_ops);
 
        if (create) {