From 03e58146ea6acf4590762412913b7470972eff01 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Thu, 22 Jan 2026 12:42:05 +0000 Subject: [PATCH] fix: Re-enable SQLite3DB::LoadPlugin() with allow_load_plugin flag This addresses an issue from PR #22 where LoadPlugin() was completely disabled. The function performs necessary initialization even when no plugin is loaded (initializes built-in sqlite3 function pointers). Changes: - Added `const bool allow_load_plugin = false` flag in LoadPlugin() - Modified `if (plugin_name)` to `if (plugin_name && allow_load_plugin == true)` - Re-enabled the LoadPlugin() call in LoadPlugins() The plugin loading code remains disabled (allow_load_plugin=false) while the function pointer initialization from built-in SQLite3 now works correctly. TODO: Revisit plugin loading safety mechanism to allow actual plugin loading. --- lib/sqlite3db.cpp | 7 ++++--- src/main.cpp | 15 +-------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/sqlite3db.cpp b/lib/sqlite3db.cpp index aeb052e368..9169ffd840 100644 --- a/lib/sqlite3db.cpp +++ b/lib/sqlite3db.cpp @@ -1065,14 +1065,15 @@ SQLite3_result::SQLite3_result() { /** * @brief Loads a SQLite3 plugin. - * + * * This function loads a SQLite3 plugin specified by the given plugin_name. * It initializes function pointers to SQLite3 API functions provided by the plugin. * If the plugin_name is NULL, it loads the built-in SQLite3 library and initializes function pointers to its API functions. - * + * * @param[in] plugin_name The name of the SQLite3 plugin library to load. */ void SQLite3DB::LoadPlugin(const char *plugin_name) { + const bool allow_load_plugin = false; // TODO: Revisit plugin loading safety mechanism proxy_sqlite3_config = NULL; proxy_sqlite3_bind_double = NULL; proxy_sqlite3_bind_int = NULL; @@ -1109,7 +1110,7 @@ void SQLite3DB::LoadPlugin(const char *plugin_name) { proxy_sqlite3_prepare_v2 = NULL; proxy_sqlite3_open_v2 = NULL; proxy_sqlite3_exec = NULL; - if (plugin_name) { + if (plugin_name && allow_load_plugin == true) { int fd = -1; fd = ::open(plugin_name, O_RDONLY); char binary_sha1_sqlite3[SHA_DIGEST_LENGTH*2+1]; diff --git a/src/main.cpp b/src/main.cpp index dad1bf4db6..c9494198f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1381,20 +1381,7 @@ void ProxySQL_Main_init() { static void LoadPlugins() { GloMyLdapAuth = NULL; if (proxy_sqlite3_open_v2 == nullptr) { - if (GloVars.sqlite3_plugin) { - proxy_warning("SQLite3 plugin loading disabled: function replacement is temporarily disabled for plugin: %s\n", GloVars.sqlite3_plugin); - } else { - proxy_warning("SQLite3 plugin function replacement is disabled; no sqlite3 plugin specified\n"); - } - /* - * Temporarily disabled: do not replace proxy_sqlite3_* symbols from plugins because - * this can change core sqlite3 behavior unexpectedly. The original call is kept - * here for reference and to make re-enabling trivial in the future. - * TODO: Revisit plugin function replacement and implement a safer mechanism - * for plugin-provided sqlite3 capabilities (create a ticket/PR and reference it here). - */ - // SQLite3DB::LoadPlugin(GloVars.sqlite3_plugin); - + SQLite3DB::LoadPlugin(GloVars.sqlite3_plugin); } if (GloVars.web_interface_plugin) { dlerror();