Skip to content

Commit 7b58681

Browse files
committed
feat: 修复database disk image is malforme
1 parent 7c2eacf commit 7b58681

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/napcat-database/src/decrypt.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ export function decryptDatabase (fileData: Buffer, passphrase: Buffer): Buffer |
6767
decrypted.copy(output, 16);
6868
// 修正 page_size 字段 (offset 16-17, big-endian)
6969
output.writeUInt16BE(PAGE_SIZE, 16);
70-
// 清零 reserved space 标志 (offset 20)
71-
output[20] = 0;
70+
// 保留原始 reserved-bytes-per-page 值 (byte 20)
71+
// NTQQ SQLCipher 使用 reserved=80 用于 B-tree 布局 (usable=4016)
72+
// 即使加密保留区 (IV+HMAC) 实际只有 48 字节
73+
// 清零会导致 SQLite 误判溢出指针,报 "database disk image is malformed"
7274
offset = PAGE_SIZE;
7375
} else {
7476
decrypted.copy(output, offset);

0 commit comments

Comments
 (0)