fix: audit batch 2 — semi-sync, DISTINCT, set ops, MERGE, storage hardening
CI / test (push) Has been cancelled
CI / raft-e2e (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / raft-e2e (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Address 12 deep-audit findings: semi-sync fail-closed on partial ack, COUNT/SUM/AVG(DISTINCT), UNION/INTERSECT/EXCEPT dedup, MERGE THEN DELETE, WAL torn-record recovery, MVCC/checkpoint/flush/compaction/WAL rewrite safety, mmap overflow bounds; remove stray protocol/scram ELF.
This commit is contained in:
@@ -68,6 +68,7 @@ proc scanWAL*(rec: CrashRecovery): seq[RecoveredEntry] =
|
||||
var txnId: uint64 = 0
|
||||
var entryCount = 0
|
||||
|
||||
const MaxWalRecordField = 64 * 1024 * 1024 # 64 MB
|
||||
while not stream.atEnd():
|
||||
var kind: uint8 = 0
|
||||
var timestamp: uint64 = 0
|
||||
@@ -77,12 +78,15 @@ proc scanWAL*(rec: CrashRecovery): seq[RecoveredEntry] =
|
||||
if stream.readData(addr kind, 1) != 1: break
|
||||
if stream.readData(addr timestamp, 8) != 8: break
|
||||
if stream.readData(addr keyLen, 4) != 4: break
|
||||
if keyLen.int > MaxWalRecordField: break
|
||||
if kind < uint8(wekPut) or kind > uint8(wekCommit): break
|
||||
|
||||
var key = newString(keyLen.int)
|
||||
if keyLen > 0:
|
||||
if stream.readData(addr key[0], keyLen.int) != keyLen.int: break
|
||||
|
||||
if stream.readData(addr valLen, 4) != 4: break
|
||||
if valLen.int > MaxWalRecordField: break
|
||||
var value = newSeq[byte](valLen.int)
|
||||
if valLen > 0:
|
||||
if stream.readData(addr value[0], valLen.int) != valLen.int: break
|
||||
|
||||
Reference in New Issue
Block a user