mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-17 11:24:14 +02:00
e3fa4a049c
A .qetz's project.sqlite comes from a file, which may be damaged, made by another tool, edited by hand (issue #1458) or made to harm. SQLite's advice for such files (https://www.sqlite.org/security.html) was only partly followed: trusted_schema was off and every name had to be a plain table. readAsUntrusted() now also turns on the defensive mode, turns off triggers and views, checks each cell's size as its page is read, limits a value to 256 MiB, and runs quick_check before anything is read, for the database read on opening and for the one a save copies kept folios from. A damaged database is now refused as "the project database is damaged", where it was "cannot be read: database disk image is malformed" or a missing row. Damage on disk was already caught before SQLite: the zip checks each entry (one flipped bit in project.sqlite: refused, "unexpected decompressed size"). quick_check does not see a changed value inside a row (49 of 400 random small changes read silently, quick_check "ok"): only the zip's checksum does. New test damagedDatabaseRefused (a page overwritten at three places): fails without this change on the message. Opening nuri (136 folios): 3.56-3.66 s with and without. ctest: the 7 container, save and lazy folio suites pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>