Title: sqlite: binding a zero-length `Uint8Array` to a parameter can result in `NULL` · Issue #67188 · nodejs/node · GitHub
Open Graph Title: sqlite: binding a zero-length `Uint8Array` to a parameter can result in `NULL` · Issue #67188 · nodejs/node
X Title: sqlite: binding a zero-length `Uint8Array` to a parameter can result in `NULL` · Issue #67188 · nodejs/node
Description: Version v22.23.4 Platform Linux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux Subsystem sqlite What steps will reproduce the bug? const { DatabaseSync } = requir...
Open Graph Description: Version v22.23.4 Platform Linux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux Subsystem sqlite What steps will reproduce ...
X Description: Version v22.23.4 Platform Linux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux Subsystem sqlite What steps will reproduce ...
Opengraph URL: https://github.com/nodejs/node/issues/67188
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite: binding a zero-length `Uint8Array` to a parameter can result in `NULL`","articleBody":"### Version\n\nv22.23.4\n\n### Platform\n\n```text\nLinux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux\n```\n\n### Subsystem\n\nsqlite\n\n### What steps will reproduce the bug?\n\n```js\nconst { DatabaseSync } = require('node:sqlite');\nconst db = new DatabaseSync(':memory:');\n\n// Expected: prints { type: 'blob' }\nconsole.log(db.prepare('SELECT typeof(?) AS type').get(new Uint8Array()));\n\n// Unexpected: prints { type: 'null' }\nconsole.log(db.prepare('SELECT typeof(?) AS type').get(new Uint8Array(new ArrayBuffer(0))));\n```\n\n### How often does it reproduce? Is there a required condition?\n\nThe above code seems to reproduce the issue deterministically.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nAll zero-length `Uint8Array`s bound to SQLite parameters should be converted to empty blobs.\n\n### What do you see instead?\n\n`new Uint8Array(new ArrayBuffer(0))` is converted to `NULL`.\n\n### Additional information\n\nThis seems to be fixed in v24 and v26.\n\nMy agent (GPT-6.1 Sol on Codex CLI) told me the following:\n\n> Reproduced on Node.js v22.23.4. `ArrayBufferViewContents` returns a non-null stack pointer for `new Uint8Array()`, but a null backing-store pointer for `new Uint8Array(new ArrayBuffer(0))`. Node passes that pointer to SQLite, which [interprets null pointers as SQL NULL](https://www.sqlite.org/c3ref/bind_blob.html), regardless of length.\n>\n> v26 includes [commit `bdf75a6`](https://github.com/nodejs/node/commit/bdf75a6c4e10) ([PR #62343](https://github.com/nodejs/node/pull/62343)), which makes the helper fall back to stack storage when the backing-store pointer is null. This fixes the SQLite behavior indirectly; the change originally addressed a crypto bug. Backporting this helper fix would resolve the v22 reproducer.","author":{"url":"https://github.com/duarte-pardal","@type":"Person","name":"duarte-pardal"},"datePublished":"2026-11-01T18:01:08Z","url":"https://github.com/nodejs/node/issues/67188"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5011c2a8-003d-9732-84fd-09544098e5c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92EC:2E5652:301E274:3D538E6:6B01CAAE |
| html-safe-nonce | d8ab1204e42eb512e006574bc9719763dd5c4e862c54d04de95b2ccc33002cf8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkVDOjJFNTY1MjozMDFFMjc0OjNENTM4RTY6NkIwMUNBQUUiLCJ2aXNpdG9yX2lkIjoiNDA3MzUwMTAyNDMyMzc1MDU3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8eee62a74d4b64dd3fe2b35356cfd47deb2a4648413abd01f4d09326572c4220 |
| hovercard-subject-tag | issue:6150215020 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67188/issue_layout |
| twitter:image | https://opengraph.githubassets.com/799d3e9492c97f809dc443194cfbe8e9f3485824ddcedbdccc01837cd7c13f90/nodejs/node/issues/67188 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/799d3e9492c97f809dc443194cfbe8e9f3485824ddcedbdccc01837cd7c13f90/nodejs/node/issues/67188 |
| og:image:alt | Version v22.23.4 Platform Linux redacted 7.0.0-38-generic #38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2 x86_64 x86_64 x86_64 GNU/Linux Subsystem sqlite What steps will reproduce ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | duarte-pardal |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width