mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:05:42 +01:00
amixer: expand local storage for item name according to kernel code
According to kernel code (snd_ctl_elem_init_enum_names() in sound/core/control.c), the maximum length of item name is 63 characters (+ 1 terminator = 64 bytes). But current amixer implementation uses 40 bytes. This causes name truncation and fail to operation. This commit fixes this bug by expanding the length of local variables. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1a19ec1538
commit
f3abdeea00
1 changed files with 9 additions and 2 deletions
|
@ -812,7 +812,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
if (snd_mixer_selem_is_enumerated(elem)) {
|
if (snd_mixer_selem_is_enumerated(elem)) {
|
||||||
int i, items;
|
int i, items;
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
char itemname[40];
|
/*
|
||||||
|
* See snd_ctl_elem_init_enum_names() in
|
||||||
|
* sound/core/control.c.
|
||||||
|
*/
|
||||||
|
char itemname[64];
|
||||||
items = snd_mixer_selem_get_enum_items(elem);
|
items = snd_mixer_selem_get_enum_items(elem);
|
||||||
printf(" Items:");
|
printf(" Items:");
|
||||||
for (i = 0; i < items; i++) {
|
for (i = 0; i < items; i++) {
|
||||||
|
@ -1255,7 +1259,9 @@ static int get_enum_item_index(snd_mixer_elem_t *elem, char **ptrp)
|
||||||
{
|
{
|
||||||
char *ptr = *ptrp;
|
char *ptr = *ptrp;
|
||||||
int items, i, len;
|
int items, i, len;
|
||||||
char name[40];
|
|
||||||
|
/* See snd_ctl_elem_init_enum_names() in sound/core/control.c. */
|
||||||
|
char name[64];
|
||||||
|
|
||||||
items = snd_mixer_selem_get_enum_items(elem);
|
items = snd_mixer_selem_get_enum_items(elem);
|
||||||
if (items <= 0)
|
if (items <= 0)
|
||||||
|
@ -1264,6 +1270,7 @@ static int get_enum_item_index(snd_mixer_elem_t *elem, char **ptrp)
|
||||||
for (i = 0; i < items; i++) {
|
for (i = 0; i < items; i++) {
|
||||||
if (snd_mixer_selem_get_enum_item_name(elem, i, sizeof(name)-1, name) < 0)
|
if (snd_mixer_selem_get_enum_item_name(elem, i, sizeof(name)-1, name) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
if (! strncmp(name, ptr, len)) {
|
if (! strncmp(name, ptr, len)) {
|
||||||
if (! ptr[len] || ptr[len] == ',' || ptr[len] == '\n') {
|
if (! ptr[len] || ptr[len] == ',' || ptr[len] == '\n') {
|
||||||
|
|
Loading…
Reference in a new issue