aboutsummaryrefslogtreecommitdiffstats
path: root/src/pinentry.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-14 23:00:15 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-15 12:45:54 -0500
commitacd1173848b4db1c733af7d3f53d24aab900b542 (patch)
treeb0a1151e390c6063169325bc4520d7b79ac50d9e /src/pinentry.rs
parentcc20037ff21a259419c7c00f6fce82ded3888d1e (diff)
downloadrbw-acd1173848b4db1c733af7d3f53d24aab900b542.tar.gz
rbw-acd1173848b4db1c733af7d3f53d24aab900b542.zip
clippy
Diffstat (limited to 'src/pinentry.rs')
-rw-r--r--src/pinentry.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pinentry.rs b/src/pinentry.rs
index b4d2bb0..ce1227f 100644
--- a/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -1,5 +1,6 @@
use crate::prelude::*;
+use std::convert::TryFrom as _;
use tokio::io::AsyncWriteExt as _;
pub async fn getpin(
@@ -163,7 +164,10 @@ fn percent_decode(buf: &mut [u8]) -> usize {
if let Some(h) = char::from(buf[read_idx + 1]).to_digit(16) {
#[allow(clippy::cast_possible_truncation)]
if let Some(l) = char::from(buf[read_idx + 2]).to_digit(16) {
- c = h as u8 * 0x10 + l as u8;
+ // h and l were parsed from a single hex digit, so they
+ // must be in the range 0-15, so these unwraps are safe
+ c = u8::try_from(h).unwrap() * 0x10
+ + u8::try_from(l).unwrap();
read_idx += 2;
}
}