]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: macro - add deep call protection (recursion)
authorJaroslav Kysela <perex@perex.cz>
Tue, 17 May 2022 17:25:20 +0000 (19:25 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 17 May 2022 17:25:28 +0000 (19:25 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/parser.c
src/ucm/ucm_local.h

index 535884942708ee20adbe453b1c81f4db4eaecec9..71b95f0e799aad81bbd7e6e28c53898c9399a1b5 100644 (file)
@@ -575,7 +575,13 @@ int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr,
                /* conditions may depend on them */
                if (err2 == 0)
                        continue;
+               uc_mgr->macro_hops++;
+               if (uc_mgr->macro_hops > 100) {
+                       uc_error("Maximal macro hops reached!");
+                       return -EINVAL;
+               }
                err3 = evaluate_macro(uc_mgr, cfg);
+               uc_mgr->macro_hops--;
                if (err3 < 0)
                        return err3;
                if (err3 == 0)
index 3f59bb2c74b0ed00e770e357f8dcc2bbf8e84d7d..2c8d004d2514eb81a2bc85aa86541120a5108e4e 100644 (file)
@@ -264,6 +264,7 @@ struct snd_use_case_mgr {
 
        /* tree with macros */
        snd_config_t *macros;
+       int macro_hops;
 
        /* local library configuration */
        snd_config_t *local_config;