From: mengdong.lin@linux.intel.com
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com,
Mengdong Lin <mengdong.lin@linux.intel.com>,
mengdong.lin@intel.com
Subject: [PATCH v6 1/3] ucm: Assure the user input card name not to exceed max size of card long name
Date: Wed, 18 Jan 2017 11:52:35 +0800 [thread overview]
Message-ID: <d8494768e045903098472b9ccf7de215eb88fe21.1484710888.git.mengdong.lin@linux.intel.com> (raw)
In-Reply-To: <cover.1484710888.git.mengdong.lin@linux.intel.com>
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Users can load a card's UCM configuration file by giving the card short
name or long name, which should not exceed the maximum card long name
defined by the kernel. The kernel uses an 80-character buffer to store
the card long name.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index c98373a..3b42e31 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -1334,6 +1334,12 @@ static int load_master_config(const char *card_name, snd_config_t **cfg)
char *env = getenv(ALSA_CONFIG_UCM_VAR);
int err;
+ if (strnlen(card_name, MAX_CARD_LONG_NAME) == MAX_CARD_LONG_NAME) {
+ uc_error("error: invalid card name %s (at most %d chars)\n",
+ card_name, MAX_CARD_LONG_NAME - 1);
+ return -EINVAL;
+ }
+
snprintf(filename, sizeof(filename)-1,
"%s/%s/%s.conf", env ? env : ALSA_USE_CASE_DIR,
card_name, card_name);
diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h
index 6d3302f..e41aafa 100644
--- a/src/ucm/ucm_local.h
+++ b/src/ucm/ucm_local.h
@@ -41,6 +41,7 @@
#include "use-case.h"
#define MAX_FILE 256
+#define MAX_CARD_LONG_NAME 80
#define ALSA_USE_CASE_DIR ALSA_CONFIG_DIR "/ucm"
#define SEQUENCE_ELEMENT_TYPE_CDEV 1
--
2.7.4
next prev parent reply other threads:[~2017-01-18 3:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 3:52 [PATCH v6 0/3] ucm: Automatically load the best config file based on the card long name mengdong.lin
2017-01-18 3:52 ` mengdong.lin [this message]
2017-01-18 3:53 ` [PATCH v6 2/3] ucm: Load device-specific configuration " mengdong.lin
2017-01-18 3:53 ` [PATCH v6 3/3] ucm: Add command 'get _file' to get the config file name of the opened card mengdong.lin
2017-01-18 10:56 ` [PATCH v6 0/3] ucm: Automatically load the best config file based on the card long name Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8494768e045903098472b9ccf7de215eb88fe21.1484710888.git.mengdong.lin@linux.intel.com \
--to=mengdong.lin@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=mengdong.lin@intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).