emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 a347b26cba2: Disable loading SQLite3 extensions when SQLite3 ve


From: Eli Zaretskii
Subject: emacs-29 a347b26cba2: Disable loading SQLite3 extensions when SQLite3 version is too old
Date: Tue, 23 May 2023 07:30:51 -0400 (EDT)

branch: emacs-29
commit a347b26cba2124496b1fa5adb75f43c8a05842a6
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Disable loading SQLite3 extensions when SQLite3 version is too old
    
    * src/sqlite.c (HAVE_LOAD_EXTENSION): Define to 1 only if
    enabling/disabling extension loading is supported as well.
    (load_dll_functions, Fsqlite_load_extension): Condition on
    HAVE_LOAD_EXTENSION, not on HAVE_SQLITE3_LOAD_EXTENSION.
    (Bug#63653)
---
 src/sqlite.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/sqlite.c b/src/sqlite.c
index 77ce61ba657..852e3746ef4 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -32,6 +32,17 @@ YOSHIDA <syohex@gmail.com>, which can be found at:
 
 #include <sqlite3.h>
 
+/* Support for loading SQLite extensions requires the ability to
+   enable and disable loading of extensions (by default this is
+   disabled, and we want to keep it that way).  The required macro is
+   available since SQLite 3.13.  */
+# if defined HAVE_SQLITE3_LOAD_EXTENSION && \
+     defined SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
+#  define HAVE_LOAD_EXTENSION 1
+# else
+#  define HAVE_LOAD_EXTENSION 0
+# endif
+
 #ifdef WINDOWSNT
 
 # include <windows.h>
@@ -77,7 +88,7 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_exec,
 DEF_DLL_FN (SQLITE_API int, sqlite3_prepare_v2,
            (sqlite3*, const char*, int, sqlite3_stmt**, const char**));
 
-# ifdef HAVE_SQLITE3_LOAD_EXTENSION
+# if HAVE_LOAD_EXTENSION
 DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
            (sqlite3*, const char*, const char*, char**));
 #  undef sqlite3_load_extension
@@ -175,7 +186,7 @@ load_dll_functions (HMODULE library)
   LOAD_DLL_FN (library, sqlite3_column_text);
   LOAD_DLL_FN (library, sqlite3_column_name);
   LOAD_DLL_FN (library, sqlite3_exec);
-# ifdef HAVE_SQLITE3_LOAD_EXTENSION
+# if HAVE_LOAD_EXTENSION
   LOAD_DLL_FN (library, sqlite3_load_extension);
   LOAD_DLL_FN (library, sqlite3_db_config);
 # endif
@@ -675,7 +686,7 @@ DEFUN ("sqlite-pragma", Fsqlite_pragma, Ssqlite_pragma, 2, 
2, 0,
                      SSDATA (concat2 (build_string ("PRAGMA "), pragma)));
 }
 
-#ifdef HAVE_SQLITE3_LOAD_EXTENSION
+#if HAVE_LOAD_EXTENSION
 DEFUN ("sqlite-load-extension", Fsqlite_load_extension,
        Ssqlite_load_extension, 2, 2, 0,
        doc: /* Load an SQlite MODULE into DB.
@@ -750,7 +761,7 @@ Only modules on Emacs' list of allowed modules can be 
loaded.  */)
     }
   return Qnil;
 }
-#endif /* HAVE_SQLITE3_LOAD_EXTENSION */
+#endif /* HAVE_LOAD_EXTENSION */
 
 DEFUN ("sqlite-next", Fsqlite_next, Ssqlite_next, 1, 1, 0,
        doc: /* Return the next result set from SET.
@@ -860,7 +871,7 @@ syms_of_sqlite (void)
   defsubr (&Ssqlite_commit);
   defsubr (&Ssqlite_rollback);
   defsubr (&Ssqlite_pragma);
-#ifdef HAVE_SQLITE3_LOAD_EXTENSION
+#if HAVE_LOAD_EXTENSION
   defsubr (&Ssqlite_load_extension);
 #endif
   defsubr (&Ssqlite_next);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]