mORMot2 DailyDaily read of upstream commits

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.

Build2.4.17634 → 2.4.17647
Commits16
Lines+1092 -575
Read4 min

14 of 14 entries · 16 commits upstream

# Entry Category Units
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.

Public API

  • SynLZdecompress1partialbehaviour-changed — Malformed input is rejected instead of reading or writing out of bounds.

Arnaud Bouchez · 14:06 UTC · view the commit on GitHub →

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.

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.

Arnaud Bouchez · 16:45 UTC · view the commit on GitHub →

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.

Public API

  • SynLZdecompress1partialbehaviour-changed — Result is the actual byte count written within maxDst.

Arnaud Bouchez · 16:10 UTC · view the commit on GitHub →

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.

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.

tobfel · 17:22 UTC · view the commit on GitHub →

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.

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.

Arnaud Bouchez · 19:34 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 08:51 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 17:33 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 13:17 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 14:50 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 14:09 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 13:15 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 15:36 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 17:29 UTC · view the commit on GitHub →

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.

Arnaud Bouchez · 14:17 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28