aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
diff options
context:
space:
mode:
authorGravatar Liz <accs@liz3.net> 2023-09-21 08:43:21 +0200
committerGravatar GitHub <noreply@github.com> 2023-09-20 23:43:21 -0700
commit2664dfad9bb0b2d83bf64ebda5b7e512b89f5e91 (patch)
tree4f51afeccdf2963315e82a6998cc2bce505642c6 /src/bun.js/bindings/sqlite/JSSQLStatement.cpp
parente0c5debc5749a38ed4699f8c02333df22046ee9b (diff)
downloadbun-2664dfad9bb0b2d83bf64ebda5b7e512b89f5e91.tar.gz
bun-2664dfad9bb0b2d83bf64ebda5b7e512b89f5e91.tar.zst
bun-2664dfad9bb0b2d83bf64ebda5b7e512b89f5e91.zip
fix: add check to sqlite extension loading logic (#5773)
The sqlite3 logic to dynamically load extensions can be disabled to save space, which macos does by default. sqlite3 provides a api to check for these compile time settings at runtime, we can use that to throw a js error rather then crashing. It is worth noting though that the api to check for these settings at runtime itself can be disabled through SQLITE_OMIT_COMPILEOPTION_DIAGS but this seams to be a edge case.
Diffstat (limited to 'src/bun.js/bindings/sqlite/JSSQLStatement.cpp')
-rw-r--r--src/bun.js/bindings/sqlite/JSSQLStatement.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
index e36d2b809..72c7d9a07 100644
--- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
+++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
@@ -695,6 +695,11 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje
return JSValue::encode(JSC::jsUndefined());
}
+ if(sqlite3_compileoption_used("SQLITE_OMIT_LOAD_EXTENSION")) {
+ throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "This build of sqlite3 does not support dynamic extension loading"_s));
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
auto entryPointStr = callFrame->argumentCount() > 2 && callFrame->argument(2).isString() ? callFrame->argument(2).toWTFString(lexicalGlobalObject) : String();
const char* entryPoint = entryPointStr.length() == 0 ? NULL : entryPointStr.utf8().data();
char* error;