[vlc-devel] [PATCH 3/5] keystore: handle module fallback in --keystore

Maxime ... mmeisson at outlook.fr
Tue Jul 30 13:01:38 CEST 2019


ex : --keystore="file{notExists:file{file=toto}:memory}"
---
 modules/keystore/memory.c |  5 +----
 src/misc/keystore.c       | 35 ++++++++++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/modules/keystore/memory.c b/modules/keystore/memory.c
index 9a93f8f068..4ad1208262 100644
--- a/modules/keystore/memory.c
+++ b/modules/keystore/memory.c
@@ -159,10 +159,7 @@ Open(vlc_keystore *p_keystore, const config_chain_t *config)
         return VLC_EGENERIC;
     p_keystore->p_sys = p_sys;
 
-    const char *const ppsz_options[] = {
-        NULL,
-    };
-    config_ChainParse(p_keystore, "keystore-", ppsz_options, config);
+    VLC_UNUSED(config); // No option to parse atm
 
     vlc_mutex_init(&p_keystore->p_sys->lock);
     p_keystore->pf_store = Store;
diff --git a/src/misc/keystore.c b/src/misc/keystore.c
index e00c4268f4..e8595654da 100644
--- a/src/misc/keystore.c
+++ b/src/misc/keystore.c
@@ -48,28 +48,46 @@ keystore_create(vlc_object_t *p_parent, const char *psz_modlist)
 {
     char *psz_name = NULL;
     config_chain_t *p_config = NULL;
+    char *next = strdup(psz_modlist);
 
-    char *next = config_ChainCreate(&psz_name, &p_config, psz_modlist);
-    if (next != NULL)
-        free(next);
+    if (next == NULL)
+        return NULL;
 
     vlc_keystore *p_keystore = vlc_custom_create(p_parent, sizeof (*p_keystore),
                                                  "keystore");
     if (unlikely(p_keystore == NULL))
+    {
+        free(next);
         return NULL;
+    }
+
+    do
+    {
+        char *tmp = config_ChainCreate(&psz_name, &p_config, next);
+        free(next);
+        next = tmp;
+
+        p_keystore->p_module = vlc_module_load(p_keystore, "keystore", psz_name, true,
+                                               keystore_start, p_keystore, p_config);
+        config_ChainDestroy(p_config);
+        free(psz_name);
+        if (p_keystore->p_module != NULL)
+        {
+            free(next);
+            break ;
+        }
+
+    } while (next != NULL);
 
-    p_keystore->p_module = vlc_module_load(p_keystore, "keystore", psz_name, true,
-                                           keystore_start, p_keystore, p_config);
-    config_ChainDestroy(p_config);
     if (p_keystore->p_module == NULL)
     {
         vlc_object_delete(p_keystore);
         return NULL;
     }
+
     assert(p_keystore->pf_store);
     assert(p_keystore->pf_find);
     assert(p_keystore->pf_remove);
-
     return p_keystore;
 }
 
@@ -80,6 +98,9 @@ vlc_keystore_create(vlc_object_t *p_parent)
     assert(p_parent);
 
     char *modlist = var_InheritString(p_parent, "keystore");
+    if (modlist == NULL)
+        return NULL;
+
     vlc_keystore *p_keystore = keystore_create(p_parent, modlist);
 
     free(modlist);
-- 
2.17.1



More information about the vlc-devel mailing list