From 738eb2142c219169fd84b734a438ebed6898329d Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager <alois1@gmx-topmail.de> Date: Thu, 10 Apr 2025 15:41:20 +0200 Subject: [PATCH] bank: make cache generation deterministic The plugins are loaded in filesystem iteration order. This would lead to the plugins.dat cache file not being built reproducibly. Sort the plugin list by path prior to writing it to achieve a consistent result. --- src/modules/bank.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/bank.c b/src/modules/bank.c index db92029cfc8a..1f70f0d364cc 100644 --- a/src/modules/bank.c +++ b/src/modules/bank.c @@ -508,6 +508,11 @@ static void AllocatePluginDir (module_bank_t *bank, unsigned maxdepth, vlc_closedir (dh); } +static int plugin_cmp(const void *first, const void *second) +{ + return strcmp((*(vlc_plugin_t **) first)->path, (*(vlc_plugin_t **) second)->path); +} + /** * Scans for plug-ins within a file system hierarchy. * \param path base directory to browse @@ -547,8 +552,10 @@ static void AllocatePluginPath(libvlc_int_t *obj, const char *path, vlc_plugin_store(plugin); } - if (mode & CACHE_WRITE_FILE) + if (mode & CACHE_WRITE_FILE) { + qsort(bank.plugins, bank.size, sizeof(vlc_plugin_t *), plugin_cmp); CacheSave(obj, path, bank.plugins, bank.size); + } free(bank.plugins); } -- GitLab