Merge pull request #1658 from signalwire/sqliteextensions

[Core] Avoid using insecure sqlite3_enable_load_extension when SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION is available.
This commit is contained in:
Andrey Volk 2022-05-19 12:46:54 +03:00 committed by GitHub
commit f220b47a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -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);