PR218: check SQLite local payload span

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Adrian D'souza
2026-10-09 00:05:52 +05:30
co-authored by Codex
parent bbcfdf085b
commit d16ab1f238
+1 -1
View File
@@ -284,7 +284,7 @@ impl Database {
let local = if payload_len <= max_local {
payload_len
} else {
let span = usable - 4;
let span = usable.checked_sub(4).ok_or("SQLite usable page size is too small")?;
let candidate = min_local.saturating_add(payload_len.checked_sub(min_local).ok_or("SQLite payload length is too small")? % span);
if candidate > max_local { min_local } else { candidate }
};