Skip to content

bind via sqlite3_bind_text64/blob64 to avoid 32-bit length truncation#1403

Merged
mattn merged 1 commit into
mattn:masterfrom
dxbjavid:bind-text64-length
Jun 5, 2026
Merged

bind via sqlite3_bind_text64/blob64 to avoid 32-bit length truncation#1403
mattn merged 1 commit into
mattn:masterfrom
dxbjavid:bind-text64-length

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

reading the bind path I noticed bindText and the blob case in bindValue narrow len through C.int before calling sqlite3_bind_text/blob. on 64-bit a parameter of 2 GiB or more wraps to a negative int32, and sqlite then derives the length via strlen over the go buffer which has no guaranteed nul terminator, so it reads past the end. a 4 GiB value instead truncates to a small positive count and binds the wrong bytes. switching the wrappers to the 64-bit variants keeps the full length so sqlite enforces SQLITE_LIMIT_LENGTH and returns SQLITE_TOOBIG. this mirrors the oversize guard already in ResultBlob/ResultText.

@codecov-commenter

codecov-commenter commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.53%. Comparing base (18cdded) to head (d1ab49c).
⚠️ Report is 88 commits behind head on master.

Files with missing lines Patch % Lines
sqlite3.go 60.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1403      +/-   ##
==========================================
+ Coverage   47.16%   51.53%   +4.37%     
==========================================
  Files          12       13       +1     
  Lines        1533     1859     +326     
==========================================
+ Hits          723      958     +235     
- Misses        669      742      +73     
- Partials      141      159      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mattn mattn merged commit 75d8c60 into mattn:master Jun 5, 2026
11 checks passed
@mattn

mattn commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Thank you

@dxbjavid

dxbjavid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge! Appreciated

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.

3 participants