aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-12-23 01:18:50 +0100
committerDaniel Mueller <deso@posteo.net>2018-12-23 12:33:07 -0800
commite1147d2f2eb98ef5a39a37fd63d98dae9a301ee2 (patch)
treea3160f07f7cc957404035d268633c701533c2057
parent048c97adcedab552e8c5b33567a06de4cb5c0f81 (diff)
downloadnitrocli-e1147d2f2eb98ef5a39a37fd63d98dae9a301ee2.tar.gz
nitrocli-e1147d2f2eb98ef5a39a37fd63d98dae9a301ee2.tar.bz2
Return UTF-8 error when handling the passphrase
Currently, invalid UTF-8 code points in the passphrase returned by pinentry are replaced with replacement characters by `String::from_utf8_lossy`. This patch changes the code to use `String::from_utf8` and returns an UTF-8 error if encountered.
-rw-r--r--nitrocli/src/commands.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
index 4a33364..4f04684 100644
--- a/nitrocli/src/commands.rs
+++ b/nitrocli/src/commands.rs
@@ -101,10 +101,8 @@ pub fn open() -> Result<()> {
let mut retry = 3;
let mut error_msg: Option<&str> = None;
loop {
- // TODO: Rethink the usage of String::from_utf8_lossy here. We may
- // not want to silently modify the password!
let passphrase = pinentry::inquire_passphrase(PIN_TYPE, error_msg)?;
- let passphrase = String::from_utf8_lossy(&passphrase);
+ let passphrase = String::from_utf8(passphrase)?;
match device.enable_encrypted_volume(&passphrase) {
Ok(()) => return Ok(()),
Err(err) => match err {