From 120581995ed911f1cfe349bb579c0b62a65f5d52 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 21 Mar 2021 19:06:50 +0000 Subject: [PATCH] fix panic on invalid key sizes --- src/key.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/key.rs b/src/key.rs index a7d8b93..9e2a254 100644 --- a/src/key.rs +++ b/src/key.rs @@ -132,7 +132,7 @@ impl str::FromStr for Key let mut this = Self::default(); let sz = std::cmp::min(KEY_SIZE, buffer.len()); - this.0.copy_from_slice(&buffer[..sz]); + (&mut this.0[..sz]).copy_from_slice(&buffer[..sz]); Ok(this) } } @@ -147,7 +147,7 @@ impl str::FromStr for IV let mut this = Self::default(); let sz = std::cmp::min(IV_SIZE, buffer.len()); - this.0.copy_from_slice(&buffer[..sz]); + (&mut this.0[..sz]).copy_from_slice(&buffer[..sz]); Ok(this) } }