From aeb43d0374f4b1fb383da088b198de55f139a280 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Sun, 7 Oct 2018 18:12:48 +1100 Subject: Ensure no buffer overflow when setting card description Sanity guard the sound card string buffers with strncpy Signed-off-by: Mark Farrugia --- configfs.c | 6 ++++-- core.c | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/configfs.c b/configfs.c index dd7b7df..bca0f56 100644 --- a/configfs.c +++ b/configfs.c @@ -173,12 +173,14 @@ static struct configfs_attribute *cfg_avirt_stream_group_attrs[] = { }; static struct configfs_group_operations cfg_avirt_stream_group_ops = { - .make_item = cfg_avirt_stream_make_item}; + .make_item = cfg_avirt_stream_make_item +}; static struct config_item_type cfg_stream_group_type = { .ct_group_ops = &cfg_avirt_stream_group_ops, .ct_attrs = cfg_avirt_stream_group_attrs, - .ct_owner = THIS_MODULE}; + .ct_owner = THIS_MODULE +}; static struct config_item_type cfg_avirt_group_type = { .ct_owner = THIS_MODULE, diff --git a/core.c b/core.c index 15df64f..96a4686 100644 --- a/core.c +++ b/core.c @@ -428,9 +428,10 @@ static int __init core_init(void) goto exit_class_container; } - strcpy(core.card->driver, "avirt-alsa-device"); - strcpy(core.card->shortname, "avirt"); - strcpy(core.card->longname, "A virtual sound card driver for ALSA"); + strncpy(core.card->driver, "avirt-alsa-dev", 16); + strncpy(core.card->shortname, "avirt", 32); + strncpy(core.card->longname, "A virtual sound card driver for ALSA", + 80); avirt_audiopath_kset = kset_create_and_add("audiopaths", NULL, &core.dev->kobj); -- cgit 1.2.3-korg