From 8c986035b852f55ad56ba0596153e5287d52c53c Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 23 Jun 2022 04:11:58 +0800 Subject: [PATCH] add trailing newline to serializations the final entry can accrue cruft after it if there is no newline --- apps/vault/src/actions.rs | 9 +++++++-- apps/vault/src/main.rs | 2 ++ apps/vault/src/ux/fido.rs | 2 +- apps/vault/src/ux/framework.rs | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/vault/src/actions.rs b/apps/vault/src/actions.rs index 6572e024d..a7621f4d2 100644 --- a/apps/vault/src/actions.rs +++ b/apps/vault/src/actions.rs @@ -305,7 +305,7 @@ impl ActionManager { ) { Ok(mut data) => { match data.write(&ser) { - Ok(_) => {} + Ok(len) => log::debug!("wrote {} bytes", len), Err(e) => { self.modals.show_notification(&format!("{}\n{:?}", t!("vault.error.internal_error", xous::LANG), e @@ -319,6 +319,7 @@ impl ActionManager { ), None).ok(); } } + log::info!("syncing..."); self.pddb.borrow().sync().ok(); } _ => {} // not valid for these other modes @@ -700,7 +701,7 @@ fn length_validator(input: TextEntryPayload) -> Option> { } pub(crate) fn serialize_password<'a>(record: &PasswordRecord) -> Vec:: { - format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}", + format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n", "version", record.version, "description", record.description, "username", record.username, @@ -732,6 +733,7 @@ pub(crate) fn deserialize_password(data: Vec::) -> Option { if let Ok(ver) = u32::from_str_radix(data, 10) { pr.version = ver } else { + log::warn!("ver error"); return None; } } @@ -743,6 +745,7 @@ pub(crate) fn deserialize_password(data: Vec::) -> Option { if let Ok(ctime) = u64::from_str_radix(data, 10) { pr.ctime = ctime; } else { + log::warn!("ctime error"); return None; } } @@ -750,6 +753,7 @@ pub(crate) fn deserialize_password(data: Vec::) -> Option { if let Ok(atime) = u64::from_str_radix(data, 10) { pr.atime = atime; } else { + log::warn!("atime error"); return None; } } @@ -757,6 +761,7 @@ pub(crate) fn deserialize_password(data: Vec::) -> Option { if let Ok(count) = u64::from_str_radix(data, 10) { pr.count = count; } else { + log::warn!("count error"); return None; } } diff --git a/apps/vault/src/main.rs b/apps/vault/src/main.rs index da958bdb6..8560d135b 100644 --- a/apps/vault/src/main.rs +++ b/apps/vault/src/main.rs @@ -209,8 +209,10 @@ fn main() -> ! { let xns = xous_names::XousNames::new().unwrap(); // TODO: add a UX loop that indicates we're waiting for a PDDB mount before moving forward + log::info!("creating vaultux"); let mut vaultux = VaultUx::new(&xns, sid, menu_mgr, actions_conn, mode.clone(), item_list, action_active.clone()); // Trigger the mode update in the actions + log::info!("vaultux created"); send_message(actions_conn, Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0) ).ok(); diff --git a/apps/vault/src/ux/fido.rs b/apps/vault/src/ux/fido.rs index cedf1faef..b959a4c56 100644 --- a/apps/vault/src/ux/fido.rs +++ b/apps/vault/src/ux/fido.rs @@ -568,7 +568,7 @@ pub(crate) fn deserialize_app_info(descriptor: Vec::) -> Option:: { } pub(crate) fn serialize_app_info<'a>(appinfo: &AppInfo) -> Vec:: { - format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}", + format!("{}:{}\n{}:{}\n{}:{}\n{}:{}\n{}:{}\n", "name", appinfo.name, "id", hex::encode(appinfo.id), "ctime", appinfo.ctime, diff --git a/apps/vault/src/ux/framework.rs b/apps/vault/src/ux/framework.rs index c7b71ba7e..1e68008d5 100644 --- a/apps/vault/src/ux/framework.rs +++ b/apps/vault/src/ux/framework.rs @@ -183,6 +183,7 @@ impl VaultUx { usb_dev: usb_device_xous::UsbHid::new(), } } + pub(crate) fn update_mode(&mut self) { self.title_dirty = true; self.filtered_list.clear(); @@ -248,7 +249,7 @@ impl VaultUx { let style = match self.pddb.borrow().get( VAULT_CONFIG_DICT, VAULT_CONFIG_KEY_FONT, - None, true, false, + None, true, true, Some(32), Some(crate::basis_change) ) { Ok(mut style_key) => {