You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bounds-check pzTail in prepare_v2/v3 span overloads
On native error paths where sqlite3_prepare_v2/v3 returns without
writing *pzTail (e.g. sqlite3LockAndPrepare returning
SQLITE_MISUSE_BKPT when the db handle fails sqlite3SafetyCheckOk or
zSql is null), the wrapper's `out byte* p_tail` stays at zero.
The subsequent `(int)(p_tail - p_sql)` can truncate to a negative
int depending on the managed-heap address, which makes
sql.Slice(len_consumed, len_remain) throw
ArgumentOutOfRangeException instead of letting the error rc
propagate.
Guard the tail-span construction behind an explicit bounds check:
only compute the slice when p_tail falls within [p_sql, p_sql +
sql.Length]; otherwise return an empty tail. Normal happy paths
are unchanged.
This is the ArgumentOutOfRangeException variant of the bug family
documented in #108, #321, #430, #479, #588; those reports surface
as AccessViolationException when the stale pointer lands in
unmapped memory. Both variants share the same call site
(raw.cs:815, already annotated "// #430 happens here").
Also adds regression tests in src/common/tests_xunit.cs that
deterministically fire the AOOR on unpatched builds by closing the
db with manual_close_v2 and growing the heap into the bit-31-clear
address range.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments