Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sqlite: refactor authz code validation logic
  • Loading branch information
araujogui committed Sep 24, 2025
commit a1553ef9d190f1e147b756be0f84d03450926d66
13 changes: 2 additions & 11 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1967,8 +1967,8 @@ int DatabaseSync::AuthorizerCallback(void* user_data,
}

Local<Value> result;
if (!retval.ToLocal(&result) || result->IsUndefined() || result->IsNull()) {
// Missing return value
if (!retval.ToLocal(&result) || result->IsUndefined() || result->IsNull() ||
!result->IsInt32()) {
Local<Value> err = Exception::TypeError(
String::NewFromUtf8(
isolate,
Expand All @@ -1978,15 +1978,6 @@ int DatabaseSync::AuthorizerCallback(void* user_data,
return SQLITE_DENY;
}

if (!result->IsInt32()) {
Local<Value> err = Exception::TypeError(
String::NewFromUtf8(
isolate, "Authorizer callback return value must be an integer")
.ToLocalChecked());
db->StoreAuthorizerError(err);
return SQLITE_DENY;
}

int32_t int_result = result.As<Int32>()->Value();
if (int_result != SQLITE_OK && int_result != SQLITE_DENY &&
int_result != SQLITE_IGNORE) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-sqlite-authz.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ suite('DatabaseSync.prototype.setAuthorizer()', () => {
assert.throws(() => {
db.exec('SELECT 1');
}, {
message: 'Authorizer callback return value must be an integer'
message: 'Authorizer callback must return an integer authorization code'
});
});

Expand Down
Loading