]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: fix the parsing of the hexadecimal prefix
authorJaroslav Kysela <perex@perex.cz>
Tue, 31 Aug 2021 07:40:42 +0000 (09:40 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 31 Aug 2021 07:42:02 +0000 (09:42 +0200)
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>
src/ucm/utils.c

index 10b21c34555acba81dff2242f7489a7caf4ff6ec..2fbc4c8cd4e3c85ca11a07f50323c9c7454c9909 100644 (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;