From 94fe0e013d40bba190b856394b90a413dec71dd4 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 7 Apr 2024 00:27:08 +0900 Subject: [PATCH 1/5] build(deps): update dependency --- Cargo.lock | 38 +++++++++++--------------------------- supply-chain/audits.toml | 25 +++++++++++++++++++++++++ supply-chain/config.toml | 12 ------------ supply-chain/imports.lock | 4 ++-- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0da2fc264..0813faad3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,12 +47,6 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -183,9 +177,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "libc", @@ -251,13 +245,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags", "libc", - "redox_syscall", ] [[package]] @@ -325,20 +318,11 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -380,7 +364,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" dependencies = [ - "bitflags 2.5.0", + "bitflags", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -403,7 +387,7 @@ version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.5.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -424,9 +408,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.57" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 54ea552e6..77bcadd76 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -22,11 +22,31 @@ user-id = 7551 # Kan-Ru Chen (kanru) start = "2024-03-26" end = "2025-03-30" +[[audits.der]] +who = "Kan-Ru Chen " +criteria = "safe-to-deploy" +version = "0.7.9" + +[[audits.getrandom]] +who = "Kan-Ru Chen " +criteria = "safe-to-deploy" +delta = "0.2.12 -> 0.2.13" + +[[audits.libredox]] +who = "Kan-Ru Chen " +criteria = "safe-to-deploy" +delta = "0.0.1 -> 0.1.3" + [[audits.log]] who = "Kan-Ru Chen " criteria = "safe-to-deploy" delta = "0.4.20 -> 0.4.21" +[[audits.redox_users]] +who = "Kan-Ru Chen " +criteria = "safe-to-deploy" +delta = "0.4.4 -> 0.4.5" + [[audits.xflags]] who = "Kan-Ru Chen " criteria = "safe-to-deploy" @@ -37,6 +57,11 @@ who = "Kan-Ru Chen " criteria = "safe-to-deploy" version = "0.3.2" +[[audits.zeroize]] +who = "Kan-Ru Chen " +criteria = "safe-to-deploy" +version = "1.7.0" + [[trusted.aho-corasick]] criteria = "safe-to-deploy" user-id = 189 # Andrew Gallant (BurntSushi) diff --git a/supply-chain/config.toml b/supply-chain/config.toml index 2d49de85e..053262b46 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -37,10 +37,6 @@ criteria = "safe-to-deploy" version = "0.2.16" criteria = "safe-to-deploy" -[[exemptions.bitflags]] -version = "1.3.2" -criteria = "safe-to-deploy" - [[exemptions.directories]] version = "5.0.1" criteria = "safe-to-deploy" @@ -109,18 +105,10 @@ criteria = "safe-to-deploy" version = "0.3.30" criteria = "safe-to-deploy" -[[exemptions.redox_syscall]] -version = "0.4.1" -criteria = "safe-to-deploy" - [[exemptions.redox_users]] version = "0.4.4" criteria = "safe-to-deploy" -[[exemptions.riff]] -version = "2.0.0" -criteria = "safe-to-deploy" - [[exemptions.rusqlite]] version = "0.31.0" criteria = "safe-to-deploy" diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 5a54f22d2..2d9df3fe9 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -107,8 +107,8 @@ user-login = "mbrubeck" user-name = "Matt Brubeck" [[publisher.syn]] -version = "2.0.57" -when = "2024-03-30" +version = "2.0.58" +when = "2024-04-03" user-id = 3618 user-login = "dtolnay" user-name = "David Tolnay" From a6bccd2cd00859d2267a0f5eb079f2278ec9af77 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 7 Apr 2024 00:31:27 +0900 Subject: [PATCH 2/5] chore(vet): move vet files to /vet --- Cargo.toml | 3 +++ {supply-chain => vet}/audits.toml | 0 {supply-chain => vet}/config.toml | 0 {supply-chain => vet}/imports.lock | 0 4 files changed, 3 insertions(+) rename {supply-chain => vet}/audits.toml (100%) rename {supply-chain => vet}/config.toml (100%) rename {supply-chain => vet}/imports.lock (100%) diff --git a/Cargo.toml b/Cargo.toml index 14c876964..5969ba794 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,9 @@ lto = true debug = true panic = "abort" +[package.metadata.vet] +store = { path = "./vet" } + [package.metadata.docs.rs] features = ["capi", "sqlite"] # rustdoc-args = ["-Zunstable-options", "--sort-modules-by-appearance"] diff --git a/supply-chain/audits.toml b/vet/audits.toml similarity index 100% rename from supply-chain/audits.toml rename to vet/audits.toml diff --git a/supply-chain/config.toml b/vet/config.toml similarity index 100% rename from supply-chain/config.toml rename to vet/config.toml diff --git a/supply-chain/imports.lock b/vet/imports.lock similarity index 100% rename from supply-chain/imports.lock rename to vet/imports.lock From 6608f4a30b719411c5c243f5896a75b974a426af Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 7 Apr 2024 07:43:08 +0900 Subject: [PATCH 3/5] fix(dict): re-enable out of bound check --- src/dictionary/trie.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dictionary/trie.rs b/src/dictionary/trie.rs index 76cc847f3..43ec91217 100644 --- a/src/dictionary/trie.rs +++ b/src/dictionary/trie.rs @@ -319,7 +319,7 @@ impl Dictionary for TrieDictionary { iter_bail_if_oob!(node.child_begin(), node.child_end(), dict.len()); let leaf_data = &dict[node.child_begin()..]; let leaf = TrieLeafView(&leaf_data[..TrieLeafView::SIZE]); - // iter_bail_if_oob!(leaf.data_begin(), leaf.data_end(), self.data.len()); + iter_bail_if_oob!(leaf.data_begin(), leaf.data_end(), data.len()); results.push(make_dict_entry(&syllables, &leaf)); if let Some(second) = child_iter.next() { next = second; From 4420489d2c10969381eef7c27764f60f36becf39 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 7 Apr 2024 09:03:05 +0900 Subject: [PATCH 4/5] fix(dict): racing in data sync --- src/dictionary/trie.rs | 6 +++--- src/dictionary/trie_buf.rs | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dictionary/trie.rs b/src/dictionary/trie.rs index 43ec91217..be99877c9 100644 --- a/src/dictionary/trie.rs +++ b/src/dictionary/trie.rs @@ -1161,11 +1161,11 @@ impl DictionaryBuilder for TrieDictionaryBuilder { fn build(&mut self, path: &Path) -> Result<(), BuildDictionaryError> { let mut tmpname = path.to_path_buf(); - let semi_random = SystemTime::now() + let pseudo_random = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) - .map(|du| du.subsec_millis()) + .map(|du| du.subsec_micros()) .unwrap_or_default(); - tmpname.set_file_name(format!("chewing-{}.dat", semi_random)); + tmpname.set_file_name(format!("chewing-{}.dat", pseudo_random)); let database = File::create(&tmpname)?; let mut writer = BufWriter::new(&database); self.write(&mut writer)?; diff --git a/src/dictionary/trie_buf.rs b/src/dictionary/trie_buf.rs index 3f432b346..90e18aa37 100644 --- a/src/dictionary/trie_buf.rs +++ b/src/dictionary/trie_buf.rs @@ -232,24 +232,31 @@ impl TrieBufDictionary { Ok(()) } - pub(crate) fn sync(&mut self) { + pub(crate) fn sync(&mut self) -> Result<(), DictionaryUpdateError> { if let Some(join_handle) = self.join_handle.take() { - if self.dirty { - // Cancel this sync if the dictionary is already dirty. - return; - } if !join_handle.is_finished() { + // Wait until previous sync is finished. self.join_handle = Some(join_handle); - return; + return Ok(()); } if let Ok(Ok(trie)) = join_handle.join() { + if self.dirty { + // Cancel this sync if the dictionary is already dirty. + return Ok(()); + } self.trie = Some(trie); self.btree.clear(); self.graveyard.clear(); } else { error!("[!] Failed to write updated user dictionary due to error."); } + } else { + // TODO: reduce reading + if !self.path.as_os_str().is_empty() { + self.trie = Some(TrieDictionary::open(&self.path)?); + } } + Ok(()) } pub(crate) fn checkpoint(&mut self) { @@ -305,10 +312,7 @@ impl Dictionary for TrieBufDictionary { } fn reopen(&mut self) -> Result<(), DictionaryUpdateError> { - if !self.path.as_os_str().is_empty() { - self.trie = Some(TrieDictionary::open(&self.path)?); - } - self.sync(); + self.sync()?; Ok(()) } From b59d08204f8eb9db99f53e922542ddc55c7c3405 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 7 Apr 2024 20:26:12 +0900 Subject: [PATCH 5/5] chore: bump version to 0.7.0 --- CMakeLists.txt | 2 +- Cargo.lock | 4 ++-- Cargo.toml | 2 +- NEWS | 23 +++++++++++++---------- fuzzer/Cargo.toml | 2 +- tests/testhelper/Cargo.toml | 2 +- tools/Cargo.toml | 4 ++-- vet/imports.lock | 8 ++++++++ 8 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3e3627db..b4e3fb89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.21.0) project(libchewing LANGUAGES C) -set(CMAKE_PROJECT_VERSION 0.7.0~rc.3) +set(CMAKE_PROJECT_VERSION 0.7.0) set(LIBCHEWING_VERSION ${CMAKE_PROJECT_VERSION}) set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION}) set(LIBCHEWING_BINARY_VERSION 1.0.0) diff --git a/Cargo.lock b/Cargo.lock index 0813faad3..76c5d7d96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,7 +67,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chewing" -version = "0.7.0-beta.2" +version = "0.7.0-beta.3" dependencies = [ "der", "directories", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "chewing-cli" -version = "0.7.0-beta.2" +version = "0.7.0-beta.3" dependencies = [ "anyhow", "chewing", diff --git a/Cargo.toml b/Cargo.toml index 5969ba794..a7d02e90a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "chewing" description = "The Chewing (酷音) intelligent Zhuyin input method." license = "LGPL-2.1-or-later" documentation = "https://docs.rs/chewing" -version = "0.7.0-beta.2" +version = "0.7.0-beta.3" rust-version = "1.70" edition = "2021" diff --git a/NEWS b/NEWS index 9a4f39c02..9b19df925 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -What's New in libchewing 0.7.0-rc.2 (Mar 31, 2024) +What's New in libchewing 0.7.0 (Apr 7, 2024) --------------------------------------------------------- This is the first beta release of the Rust rewrite. The library has been tested @@ -7,10 +7,9 @@ not crash for normal use. Now we invite power users to daily drive the beta release in order to find more subtle bugs. The Rust rewrite is ABI compatiable with previous releases. The most notable -difference with the C version includes a new portable system dictionary format -and two new user dictionary format. Users with existing user phrase dictionary -will be automatically migrated to either a new sqlite3 schema or CDB based -format depending on compile time configuration. Old files will be backed up +difference with the C version includes a new portable dictionary format that can +be used both as system dictionary and user dictionary. Users with existing user +phrase dictionary will be automatically migrated. Old files will be backed up automatically. With these change we will be able to support dictionary sharing and loading multiple dictionaries in future releases. @@ -23,23 +22,27 @@ and loading multiple dictionaries in future releases. * Added - Added Colemak-DH ANSI/Orth layout support + - Replace bespoke RIFF+TLV file format with standard DER format (rust) - Supporting migrating user dictionary file to new format. (rust) - Allow creating in memory user dictionary (rust) - New `chewing-cli` tool can be used to create or inspect dictionary files. (rust) - New `chewing-cli` tool can dump dictionary as or import from CSV file. (rust) + - Audit dependencies using cargo-vet (rust) * Changed - - New trie dictionary format now has built-in checksum. (rust) + - Buffer user dictionary changes and flush in background without blocking main + thread (rust) * Bug fixed - Some unsigned underflow issue found by afl++ (rust) - Skip symbol selection if preedit buffer is empty (rust) - Allow numlock in selection mode (rust) - Avoid infinite recursion (rust) - - Ensure to return KeyBehavior::Commit when we push to commit buffer - - Adjust selection offset after delete symbols - - Disable trace logging if no logger is enabled - - Should not start selection in English mode + - Ensure to return KeyBehavior::Commit when we push to commit buffer (rust) + - Adjust selection offset after delete symbols (rust) + - Disable trace logging if no logger is enabled (rust) + - Should not start selection in English mode (rust) + - Use offset to select from paginated phrase list (rust) * Documentation - Added document for fuzzers (rust) diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index eff780d9c..4879baca9 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] afl = "0.15.4" -chewing = { version = "0.7.0-beta.2", path = "..", features = ["capi"] } +chewing = { version = "0.7.0-beta.3", path = "..", features = ["capi"] } log = "0.4.21" env_logger = "0.10.0" xflags = "0.3.2" diff --git a/tests/testhelper/Cargo.toml b/tests/testhelper/Cargo.toml index f7f131894..5529e86c8 100644 --- a/tests/testhelper/Cargo.toml +++ b/tests/testhelper/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -chewing = { version = "0.7.0-beta.2", path = "../..", features = ["capi"] } +chewing = { version = "0.7.0-beta.3", path = "../..", features = ["capi"] } [features] sqlite = ["chewing/sqlite"] diff --git a/tools/Cargo.toml b/tools/Cargo.toml index f827d0cad..42251ea61 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -2,10 +2,10 @@ name = "chewing-cli" description = "Tools of the Chewing (酷音) intelligent Zhuyin input method." license = "LGPL-2.1-or-later" -version = "0.7.0-beta.2" +version = "0.7.0-beta.3" edition = "2021" [dependencies] anyhow = "1.0.0" -chewing = { version = "0.7.0-beta.2", path = "..", features = ["sqlite"] } +chewing = { version = "0.7.0-beta.3", path = "..", features = ["sqlite"] } xflags = "0.3.2" diff --git a/vet/imports.lock b/vet/imports.lock index 2d9df3fe9..c50f1bd61 100644 --- a/vet/imports.lock +++ b/vet/imports.lock @@ -1,6 +1,14 @@ # cargo-vet imports lock +[[unpublished.chewing]] +version = "0.7.0-beta.3" +audited_as = "0.7.0-beta.2" + +[[unpublished.chewing-cli]] +version = "0.7.0-beta.3" +audited_as = "0.7.0-beta.2" + [[publisher.aho-corasick]] version = "1.1.3" when = "2024-03-20"