summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Mühlbacher <tmuehlbacher@posteo.net>2024-06-15 23:45:06 +0200
committerThomas Mühlbacher <tmuehlbacher@posteo.net>2024-06-18 20:56:15 +0200
commite4271d7a3e5c0197b2a71eb001b93c3d7601847f (patch)
tree6de857fe71312bc4bac0fd02722565536b44995a
parent87ab1fd7edf331cdb5fe3e447d18e9447e1b2149 (diff)
fix(key): remove any newlines from passphrase
To match the behavior of the C code and because there may be newlines under some conditions. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
-rw-r--r--src/key.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/key.rs b/src/key.rs
index 54959d6e..44f2ad67 100644
--- a/src/key.rs
+++ b/src/key.rs
@@ -158,7 +158,7 @@ impl Passphrase {
line
};
- Ok(Self(CString::new(passphrase.as_str())?))
+ Ok(Self(CString::new(passphrase.trim_end_matches('\n'))?))
}
pub fn new_from_file(sb: &bch_sb_handle, passphrase_file: impl AsRef<Path>) -> Result<Self> {
@@ -172,6 +172,6 @@ impl Passphrase {
let passphrase = Zeroizing::new(fs::read_to_string(passphrase_file)?);
- Ok(Self(CString::new(passphrase.as_str())?))
+ Ok(Self(CString::new(passphrase.trim_end_matches('\n'))?))
}
}