fix: 修复 review 发现的 4 个高优先级 bug

- Cargo.toml: libc 依赖范围从 macos 改为 unix(修复 Linux 编译失败)
- scanner/macos.rs: VM_REGION_BASIC_INFO_COUNT_64 改为硬编码 9(修复 mach_vm_region 调用失败)
- crypto/wal.rs: WAL 第一页帧不走主 DB 第一页特殊路径(修复 WAL 数据损坏)
- daemon/query.rs: 全局搜索传入正确 names_map(修复 sender 字段为空)
This commit is contained in:
jackwener
2026-04-16 14:48:03 +08:00
parent d475f6219b
commit 993ac1ed47
7 changed files with 28 additions and 6 deletions
+3 -1
View File
@@ -61,7 +61,9 @@ pub fn apply_wal(wal_path: &Path, out_path: &Path, enc_key: &[u8; 32]) -> Result
page_buf.resize(PAGE_SZ, 0);
}
let dec = decrypt_page(enc_key, &page_buf, pgno)?;
// WAL 帧中的页数据不含 SALT 头,所以对 pgno=1 的帧也用普通页解密路径
// (区别于主数据库第一页需要跳过 SALT 并写入 SQLite 魔数)
let dec = decrypt_page(enc_key, &page_buf, if pgno == 1 { 2 } else { pgno })?;
let file_offset = (pgno as u64 - 1) * PAGE_SZ as u64;
db_file.seek(SeekFrom::Start(file_offset))?;
db_file.write_all(&dec)?;
+2 -1
View File
@@ -259,13 +259,14 @@ pub async fn q_search(
let until2 = until;
let limit2 = limit * 3;
let names_map2 = names.map.clone();
let found: Vec<Value> = tokio::task::spawn_blocking(move || {
let conn = Connection::open(&db_path)?;
let mut all = Vec::new();
for (tname, display, uname) in &table_list {
let is_group = uname.contains("@chatroom");
let rows = search_in_table(&conn, tname, &uname, is_group,
&HashMap::new(), &kw2, since2, until2, limit2)?;
&names_map2, &kw2, since2, until2, limit2)?;
for mut row in rows {
if row.get("chat").map(|v| v.as_str().unwrap_or("")).unwrap_or("").is_empty() {
if let Some(obj) = row.as_object_mut() {
+2 -3
View File
@@ -152,9 +152,8 @@ fn scan_memory(task: mach_port_t) -> Result<Vec<(String, String)>> {
let mut results: Vec<(String, String)> = Vec::new();
let mut addr: mach_vm_address_t = 0;
// VM_REGION_BASIC_INFO_COUNT_64 = sizeof(vm_region_basic_info_64) / sizeof(int32_t)
let info_count_expected: mach_msg_type_number_t =
(std::mem::size_of::<VmRegionBasicInfo64>() / 4) as u32;
// VM_REGION_BASIC_INFO_COUNT_64 = 9(来自 <mach/vm_region.h>,固定值,不能用 sizeof 计算)
let info_count_expected: mach_msg_type_number_t = 9;
loop {
let mut size: mach_vm_size_t = 0;