ucm: fix the parsing of the hexadecimal prefix

The safe_strtol() function use strtol() which expects
to have the '0x' prefix for the hexadecimal number (when
base argument is zero).

BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1553
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-08-31 09:40:42 +02:00
parent 7d40a76ef5
commit 4a52ae4c32

View file

@ -811,7 +811,7 @@ void uc_mgr_card_close(snd_use_case_mgr_t *uc_mgr)
*/
const char *uc_mgr_alibcfg_by_device(snd_config_t **top, const char *name)
{
char buf[5];
char buf[7];
long card_num;
snd_config_t *config;
snd_use_case_mgr_t *uc_mgr;
@ -819,8 +819,10 @@ const char *uc_mgr_alibcfg_by_device(snd_config_t **top, const char *name)
if (strncmp(name, "_ucm", 4) || strlen(name) < 12 || name[8] != '.')
return NULL;
strncpy(buf, name + 4, 4);
buf[4] = '\0';
buf[0] = '0';
buf[1] = 'x';
strncpy(buf + 2, name + 4, 4);
buf[6] = '\0';
err = safe_strtol(buf, &card_num);
if (err < 0 || card_num < 0 || card_num > 0xffff)
return NULL;