[pve-devel] [PATCH proxmox-perl-rs 1/2] pve-rs/tfa: fix off by one trimming

Dominik Csapak d.csapak at proxmox.com
Fri Nov 12 09:58:13 CET 2021


to is the last *valid* character, and ranges end by default with one
less, so extend the range to the actual last character

this fixes an issue that we could not parse old configs with
non-padded base64 values

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 pve-rs/src/tfa/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pve-rs/src/tfa/mod.rs b/pve-rs/src/tfa/mod.rs
index df192b4..44cec74 100644
--- a/pve-rs/src/tfa/mod.rs
+++ b/pve-rs/src/tfa/mod.rs
@@ -660,7 +660,7 @@ fn trim_ascii_whitespace_start(data: &[u8]) -> &[u8] {
 
 fn trim_ascii_whitespace_end(data: &[u8]) -> &[u8] {
     match data.iter().rposition(|&c| !c.is_ascii_whitespace()) {
-        Some(to) => &data[..to],
+        Some(to) => &data[..=to],
         None => data,
     }
 }
-- 
2.30.2






More information about the pve-devel mailing list