The converter accepts short reads, so a truncated snapshot can be reported as successfully converted while storing incomplete script data. For example, a final script declaring four bytes but containing only one is written to SQLite and the process exits successfully.
Read each serialized field at its expected length and fail when the input ends early. Keep the final EOF probe unchanged.
Add regression coverage for truncated metadata, CompactSize and VarInt values, all compressed script types, and end-to-end conversion of valid and truncated snapshots.
Validation: python3 contrib/utxo-tools/test_utxo_to_sqlite.py passes all four test methods with this change and fails against the unchanged base revision. The full Bitcoin Core test suite was not run.
This change and its tests were prepared with AI assistance. It does not make output creation atomic; an earlier committed batch may remain after a later input error.