summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-12-14 09:29:06 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-12-14 09:29:13 +0100
commit8c0f9be0d1ace6437d4c604b9af79b7b0006dec4 (patch)
treeb664ec843fc4c1f420812023edd9eaa160e312a2 /test
parentb8e6beaab01e9c7eaf5cdc12a34987402fb9b72f (diff)
downloademacs-8c0f9be0d1ace6437d4c604b9af79b7b0006dec4.tar.gz
Only allow SQLite extensions from an allowlist
* src/sqlite.c (Fsqlite_load_extension): Only allow extensions from an allowlist.
Diffstat (limited to 'test')
-rw-r--r--test/src/sqlite-tests.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/src/sqlite-tests.el b/test/src/sqlite-tests.el
index 6a88f0fd6ca..d1076e481c4 100644
--- a/test/src/sqlite-tests.el
+++ b/test/src/sqlite-tests.el
@@ -182,4 +182,36 @@
(sqlite-close db)
(should-error (sqlite-select db "select * from test6"))))
+(ert-deftest sqlite-load-extension ()
+ (skip-unless (sqlite-available-p))
+ (let (db)
+ (setq db (sqlite-open))
+ (should-error
+ (sqlite-load-extension db "/usr/lib/sqlite3/notpcre.so"))
+ (should-error
+ (sqlite-load-extension db "/usr/lib/sqlite3/n"))
+ (should-error
+ (sqlite-load-extension db "/usr/lib/sqlite3/"))
+ (should-error
+ (sqlite-load-extension db "/usr/lib/sqlite3"))
+ (should
+ (memq
+ (sqlite-load-extension db "/usr/lib/sqlite3/pcre.so")
+ '(nil t)))
+
+ (should-error
+ (sqlite-load-extension
+ db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_notcsvtable.so"))
+ (should-error
+ (sqlite-load-extension
+ db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtablen.so"))
+ (should-error
+ (sqlite-load-extension
+ db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtable"))
+ (should
+ (memq
+ (sqlite-load-extension
+ db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtable.so")
+ '(nil t)))))
+
;;; sqlite-tests.el ends here