Act nowcan affect a running system
SynLZ hardening closes invalid-input crashes and overruns
The safe partial SynLZ decoder is hardened against malformed input and now reports the bytes actually produced, making this an important update for services that accept compressed data from untrusted sources. SQLite transaction tracking, SQL proxy statement reuse, POSIX polling and cross-bitness database metadata also receive production-facing fixes. Delphi and FPC teams should land on the final build and recompile code that exposes the changed public record fields or Execute overloads.
TL;DR
- Upgrade services that call SynLZdecompress1partial on untrusted data: malformed streams could previously crash or overrun a buffer.
- SynLZdecompress1partial now returns the bytes actually written, not the advertised or requested size.
- SQLite transaction state now follows sqlite3_get_autocommit, including transactions opened by direct SQL and state changes after errors.
- TSqlDBProxyStatement can be reset and reused without retaining rows, columns or an update count.
- Database column size fields now use integer so proxy metadata serializes consistently between 32-bit and 64-bit peers.
- Use build 2.4.17647 for the complete fixes, including POSIX polling and the new trusted-library LoadExtension wrapper.
Upgrade advice
Land on build 2.4.17647, not an intermediate SynLZ optimization revision. Recompile Delphi and FPC database/proxy code, verify any code that depends on PtrInt-sized TSqlDBColumnDefine or TSqlDBProcColumnDefine fields, and test partial decompression with truncated input, direct-SQL SQLite transactions, repeated TSqlDBProxyStatement reuse and POSIX socket subscription holes.
14 of 14 entries · 16 commits upstream
1
High
Malformed SynLZ input can no longer overrun the safe decoder
SynLZdecompress1partial now validates control words, match tokens, extended lengths and hash offsets before reading or copying, clips writes to maxDst and rejects invalid input with a zero result.
Security
mormot.core.compress
16008631+30-15
core: hardened SynLZdecompress1partial() from invalid input
Impact
The function documented for untrusted input no longer follows paths that could cause a general protection fault or silently write past the destination. The protection applies to both Delphi and FPC pure-Pascal builds.
Upgrade recommended
Prioritize build 2.4.17647 wherever SynLZdecompress1partial sees external data, and add truncated and malformed corpus cases to service-level tests.
Public API
SynLZdecompress1partialbehaviour-changed — Malformed input is rejected instead of reading or writing out of bounds.
Units
2
High
SQLite transaction state now follows the engine
TransactionActive now reads sqlite3_get_autocommit under the database lock instead of a local flag. Begin, commit and rollback use the same locked state, while scalar Execute overloads change their output parameter from out to var.
Fixes
mormot.db.raw.sqlite3
f08998d8+123-88
db: fixed SQLite3 transaction status with TSqlDatabase
Impact
Transactions opened through direct SQL and state changes caused by SQL errors are now visible, so commit and rollback are no longer skipped because of stale wrapper state. Normal variable call sites remain straightforward, but method references or overrides matching the out signature require review in Delphi and FPC.
Upgrade recommended
Upgrade to build 2.4.17647, recompile database code and test BEGIN/COMMIT/ROLLBACK issued both through methods and direct SQL, including an error path.
Public API
TSqlDataBase.TransactionActivebehaviour-changed — State is derived from sqlite3_get_autocommit.TSqlDataBase.Execute(aSql; var aValue; NoLog)signature-changed — aValue changed from out to var.TSqlRequest.Execute(aDB; aSql; var aValue)signature-changed — aValue changed from out to var.
3
High
Partial SynLZ decompression reports only completed output
SynLZdecompress1partial now limits work by maxDst, tightens source-boundary checks and returns the number of bytes successfully written even for truncated or malformed input.
Fixes
mormot.core.compress
5de5c1b7+27-24
core: SynLZdecompress1partial() returns bytes written in dst[]
Impact
Callers no longer receive the requested or header-advertised size when fewer bytes were decoded. Delphi and FPC code that assumed the old return value must consume only Result bytes.
Upgrade recommended
Upgrade to build 2.4.17647 and audit every SynLZdecompress1partial caller to use its return value as the authoritative output length.
Public API
SynLZdecompress1partialbehaviour-changed — Result is the actual byte count written within maxDst.
Units
4
High
Prepared SQL proxy statements can be reset and executed again
TSqlDBProxyStatement now overrides ReleaseRows and Reset to clear buffered rows, readers, column metadata and the update count before delegating to inherited cleanup.
Fixes
mormot.db.proxy+1
d33bf358+43-0
db: TSqlDBProxyStatement can now be executed several times
Impact
The normal Bind, ExecutePrepared, Step, Reset loop works repeatedly instead of retaining the previous result and raising an Invalid ExecutePrepared call. The behavior is shared by Delphi and FPC proxy clients.
Upgrade recommended
Upgrade to build 2.4.17647 and rerun each reusable proxy statement with different parameter values and result shapes.
Public API
TSqlDBProxyStatement.ReleaseRowsbehaviour-changed — Proxy row and column state is cleared before inherited cleanup.TSqlDBProxyStatement.Resetbehaviour-changed — Reset now clears rows, columns and fUpdateCount for reuse.
5
High
Database metadata now crosses 32-bit and 64-bit proxies consistently
ColumnLength, ColumnPrecision and ColumnScale in TSqlDBColumnDefine and TSqlDBProcColumnDefine changed from PtrInt to integer, and TSqlDBIndexDefine gained RTTI registration for proxy serialization.
Compiler & platform
mormot.db.core+1
adb3f46c+16-10
db: fixed TSqlDBColumnDefine/TSqlDBIndexDefine type fields
Impact
Proxy metadata no longer changes wire width with the process bitness. The public packed-record layout changes on 64-bit Delphi and FPC targets, so code relying on PtrInt fields or binary record layout must be rebuilt and reviewed.
Upgrade recommended
Rebuild both ends of any SQL proxy connection on build 2.4.17647 and test metadata exchange between 32-bit and 64-bit processes.
Public API
TSqlDBColumnDefine.ColumnLength/ColumnPrecision/ColumnScalesignature-changed — Field type changed from PtrInt to integer.TSqlDBProcColumnDefine.ColumnLength/ColumnPrecision/ColumnScalesignature-changed — Field type changed from PtrInt to integer.TSqlDBIndexDefinebehaviour-changed — RTTI metadata is now registered for proxy serialization.
6
Medium
POSIX socket subscriptions advance past vacant poll slots
TPollSocketPoll.Subscribe now advances its pollfd pointer while scanning a list containing vacant entries; the old loop repeatedly inspected the same slot.
Fixes
mormot.net.sock
e7802a7f+3-2
net: fixed TPollSocketPoll.Subscribe
Impact
On macOS, BSD and other poll-based POSIX backends, later sockets and free slots are found correctly, avoiding duplicate or misplaced subscriptions after holes appear.
Upgrade recommended
Use build 2.4.17647 and stress subscribe/unsubscribe cycles that leave holes in the poll array on each POSIX target you ship.
Units
7
Medium
SQLite extensions can be loaded without exposing the SQL loader
TSqlDataBase.LoadExtension loads a trusted library through sqlite3_load_extension, temporarily enables only the C API when required, restores the prior setting and raises ESqlite3Exception on failure.
New features
mormot.db.raw.sqlite3
6302d231+71-7
db: new TSqlDataBase.LoadExtension wrapper method
Impact
Delphi and FPC applications gain a locked wrapper that does not enable the SQL load_extension function. Runtime SQLite builds still need the db_config, load_extension and free entry points.
Worth a look
Use only trusted extension paths and verify that the deployed SQLite library exposes the required C entry points.
Public API
TSqlDataBase.LoadExtensionadded — Adds aPath and optional aEntryPoint parameters.
8
Low
Pure Pascal SynLZ decoding batches consecutive literals
The pure Pascal decoders use bit-scan helpers to identify literal runs, copy them in batches and share new context helpers across full and partial decoding.
Performance
mormot.core.compress
d9df1936+213-142
core: faster SynLZ decompression in pure pascal
Impact
Pure Pascal Delphi and FPC paths get faster without a format or signature change. Later commits in the same edition complete the invalid-input and return-count behavior, so deploy the final build rather than this intermediate revision.
Units
9
Low
The i386 SynLZ decoder consumes literal runs in bulk
The 32-bit Intel assembly path was rewritten to count literal runs with BSF and copy them in dword blocks before resuming match decoding.
Performance
mormot.core.compress
80d4fded+147-106
core: i386 asm using BSF opcode of SynLZdecompress1()
Impact
Win32 and other i386 builds get a decoder optimization; the SynLZ stream format and Delphi/FPC APIs do not change.
Units
10
Low
The x64 SynLZ loop skips literal runs with BSF
The x64 assembly decompressor was rewritten to find consecutive literal bits with BSF and perform bulk copies before processing the next match.
Performance
mormot.core.compress
8aad19cd+128-99
core: rewritten SynLZdecompress1() x64 asm to use BSF opcode
Impact
This is an x64 backend optimization with no stream-format or public-API change; the commit notes only a small gain over the pure Pascal path.
Units
11
Low
Modern Delphi builds use native bit-scan intrinsics
Delphi 10.4 and newer use CountLeadingZeros32/64 under HASBITINTRINSICS, while older Delphi keeps assembly paths and the Delphi i386 BSRqword implementation is corrected.
Performance
mormot.core.base+1
6ee06654+87-50
core: properly use CountTrailingZeros32() intrinsic on Delphi 10.4 and up
Impact
Modern Delphi gets compiler intrinsics and Delphi i386 gets the corrected fallback; FPC already follows its intrinsic path. Public signatures are unchanged.
12
Low
The x64 SynLZ decoder copies long matches with SSE2
The x64 assembly decoder uses overlapping 64-bit copies for short matches and MOVDQU SSE2 loops for matches longer than 16 bytes.
Performance
mormot.core.compress
1c41026c+32-26
core: SSE2 version of x64 asm SynLZ decompression function
Impact
Only the x64 assembly backend changes; compressed format, public API and Delphi/FPC application code are unchanged.
Units
13
Low
Partial SynLZ output guards receive malformed-stream coverage
Tests now exercise truncated control words, incomplete matches, overlap and destination boundaries while checking returned byte counts and guard bytes.
Tests
test.core.base
77b0d3ee+76-2
test: coverage of partial SynLZDecompress1() output
Impact
No Delphi or FPC application API changes; the regression suite better protects the safe partial decoder contract.
Units
14
Low
Every requested SynLZ prefix length is now regression-tested
The suite requests every possible partial output length and verifies the exact return count, decoded bytes and untouched guard regions.
Tests
test.core.base
5380c908+10-4
test: more complete SynLZDecompress1partial() testing
Impact
No application-code impact; Delphi and FPC regression coverage now detects underwrites and overwrites at every partial length.