From f07a4426824bea832b3408466a2a0f213cfa5e1f Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 18 May 2022 23:45:00 +0300 Subject: [PATCH] [Core] Avoid using insecure sqlite3_enable_load_extension when SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION is available. --- src/switch_core_db.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/switch_core_db.c b/src/switch_core_db.c index d3701ce91f..afda66af62 100644 --- a/src/switch_core_db.c +++ b/src/switch_core_db.c @@ -181,9 +181,14 @@ SWITCH_DECLARE(int) switch_core_db_load_extension(switch_core_db_t *db, const ch int ret = 0; char *err = NULL; +#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION + sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0); + ret = sqlite3_load_extension(db, extension, 0, &err); +#else sqlite3_enable_load_extension(db, 1); ret = sqlite3_load_extension(db, extension, 0, &err); sqlite3_enable_load_extension(db, 0); +#endif if (err) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LOAD EXTENSION ERR [%s]\n", err);