Skip to content

fixed undefined behavior#1864

Closed
gms1 wants to merge 25 commits intoTryGhost:masterfrom
gms1:fix/null-pointer-empty-blob
Closed

fixed undefined behavior#1864
gms1 wants to merge 25 commits intoTryGhost:masterfrom
gms1:fix/null-pointer-empty-blob

Conversation

@gms1
Copy link
Copy Markdown
Contributor

@gms1 gms1 commented Mar 28, 2026

when copying from null pointer
as pointed out here:
#1832


Note

Medium Risk
Medium risk because it touches native BLOB handling and significantly changes packaging/release automation (scoped npm name, CI publishing, bundled SQLite version), which could affect consumers and distribution.

Overview
Fixes undefined behavior in native statement BLOB binding by skipping memcpy when len == 0, and adds a regression test to ensure empty BLOBs round-trip as zero-length Buffers.

Updates the project for the forked distribution: renames the npm package to @homeofthings/sqlite3 (version 6.1.0), updates docs/links, adjusts the bundled SQLite version in common-sqlite.gypi, and adds new developer docs plus a tinybench-based benchmark suite.

Modernizes repo hygiene and automation by adding .editorconfig/.gitattributes, tightening ESLint setup and introducing yarn lint, and expanding GitHub Actions CI with version-tag verification, a dedicated lint job, frozen installs, and an npm publish step on tags.

Written by Cursor Bugbot for commit 70e8673. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This pull request performs a comprehensive fork takeover and modernization of a Node.js SQLite3 binding library. Changes include rebranding the package from sqlite3/TryGhost/node-sqlite3 to @homeofthings/sqlite3/gms1/node-sqlite3, updating the CI workflow to add version verification and automated npm publishing, refactoring benchmark tooling from callback-based to async/await with tinybench, downgrading the bundled SQLite version from 3.52.0 to 3.51.3, and adding comprehensive development and build documentation. Configuration files are standardized with .editorconfig and .eslintrc.js updates, and various test improvements and minor code fixes are applied throughout.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "fixed undefined behavior" is vague and does not convey specific information about what behavior was fixed or which component was affected. Consider revising the title to be more specific, such as "Fix undefined behavior in BLOB binding when length is zero" to clearly indicate the nature and scope of the fix.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the core fix for undefined behavior in BLOB handling and providing context via a referenced issue link, along with additional changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/null-pointer-empty-blob

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gms1 gms1 closed this Mar 28, 2026
@gms1 gms1 deleted the fix/null-pointer-empty-blob branch March 28, 2026 07:21
@gms1 gms1 restored the fix/null-pointer-empty-blob branch March 28, 2026 07:22
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

run: yarn install --frozen-lockfile --ignore-scripts

- name: Publish to npm
run: npm publish
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI publish job likely missing npm authentication configuration

Medium Severity

The publish-npm job uses actions/setup-node with registry-url, which creates an .npmrc referencing ${NODE_AUTH_TOKEN}, but no NODE_AUTH_TOKEN environment variable is provided on the npm publish step. While id-token: write suggests OIDC trusted publishing was intended, the actions/setup-node registry-url option is known to interfere with OIDC by injecting an unresolved token reference. The npm publish call likely needs either a --provenance flag or NODE_AUTH_TOKEN set explicitly.

Fix in Cursor Fix in Web

await promisifyRun(db, 'COMMIT');
resolve();
});
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async callback breaks serialize mode in benchmarks

Low Severity

Passing an async callback to db.serialize() breaks serialization. The native Serialize implementation calls the callback synchronously and restores db->serialize to its prior value immediately after the callback returns. An async function returns a Promise at its first await, so serialize mode is restored to false before the remaining queued operations (the parallelize block, COMMIT) execute. This means those operations run in parallel mode, defeating the purpose of serialize and producing unreliable benchmark results.

Additional Locations (1)
Fix in Cursor Fix in Web

@gms1 gms1 deleted the fix/null-pointer-empty-blob branch March 28, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants