From 3457f9cb43c7232e620ef4d8901f04a72ab3a349 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 18 Mar 2023 10:08:57 -0400 Subject: [PATCH] disallow blank encryption passkeys (#186) fixes #185 --- src/accountmanager.rs | 5 +++++ src/main.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/accountmanager.rs b/src/accountmanager.rs index f6d2597..2160055 100644 --- a/src/accountmanager.rs +++ b/src/accountmanager.rs @@ -86,6 +86,11 @@ impl Manifest { /// Tells the manifest to keep track of the encryption passkey, and use it for encryption when loading or saving accounts. pub fn submit_passkey(&mut self, passkey: Option) { + if let Some(p) = passkey.as_ref() { + if p.is_empty() { + panic!("Encryption passkey cannot be empty"); + } + } if passkey.is_some() { debug!("passkey was submitted to manifest"); } else { diff --git a/src/main.rs b/src/main.rs index 11fc06f..6ec435f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -641,6 +641,12 @@ fn do_subcmd_encrypt( let mut passkey; loop { passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok(); + if let Some(p) = passkey.as_ref() { + if p.is_empty() { + error!("Passkey cannot be empty, try again."); + continue; + } + } let passkey_confirm = rpassword::prompt_password_stdout("Confirm encryption passkey: ").ok(); if passkey == passkey_confirm {