From 15d5b09dcbf5c73626b5167c55a8ecdb54e21c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 15 Nov 2021 18:47:15 +0100 Subject: [PATCH] pkstrings: reuse vec we're already consuming in TryFrom> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- pkstrings/src/pkstring.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkstrings/src/pkstring.rs b/pkstrings/src/pkstring.rs index 7d044e3..8c79768 100644 --- a/pkstrings/src/pkstring.rs +++ b/pkstrings/src/pkstring.rs @@ -162,7 +162,13 @@ impl TryFrom> for PKString { type Error = Error; fn try_from(data: Vec) -> Result { - PKString::try_from(data.as_slice()) + for ord in &data { + if ! in_range(*ord) { + return Err(Error::InvalidByte(*ord)) + } + } + + Ok(PKString(data)) } }