mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
ucm: Assure the user input card name not to exceed max size of card long name
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> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
24e63b7527
commit
2b9b3f0134
2 changed files with 7 additions and 0 deletions
|
|
@ -1335,6 +1335,12 @@ static int load_master_config(const char *card_name, snd_config_t **cfg)
|
||||||
char *env = getenv(ALSA_CONFIG_UCM_VAR);
|
char *env = getenv(ALSA_CONFIG_UCM_VAR);
|
||||||
int err;
|
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,
|
snprintf(filename, sizeof(filename)-1,
|
||||||
"%s/%s/%s.conf", env ? env : ALSA_USE_CASE_DIR,
|
"%s/%s/%s.conf", env ? env : ALSA_USE_CASE_DIR,
|
||||||
card_name, card_name);
|
card_name, card_name);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include "use-case.h"
|
#include "use-case.h"
|
||||||
|
|
||||||
#define MAX_FILE 256
|
#define MAX_FILE 256
|
||||||
|
#define MAX_CARD_LONG_NAME 80
|
||||||
#define ALSA_USE_CASE_DIR ALSA_CONFIG_DIR "/ucm"
|
#define ALSA_USE_CASE_DIR ALSA_CONFIG_DIR "/ucm"
|
||||||
|
|
||||||
#define SEQUENCE_ELEMENT_TYPE_CDEV 1
|
#define SEQUENCE_ELEMENT_TYPE_CDEV 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue