fix substraction overflow

This commit is contained in:
Alex 2022-12-15 17:03:12 +01:00
parent eae4a0443a
commit 7dc139737c
Signed by: lx
GPG Key ID: 0E496D15096376BE
2 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@
name = "nettext"
description = "A text-based data format for cryptographic network protocols"
authors = ["Alex Auvolat <alex@adnab.me>"]
version = "0.3.2"
version = "0.3.3"
edition = "2021"
license = "AGPL-3.0"
readme = "README.md"

View File

@ -32,7 +32,10 @@ pub fn encode(bytes: &[u8], allow_whitespace: bool) -> Vec<u8> {
// We stop at the first position where we find three consecutive
// characters to encode as-is
let mut b64end = bytes.len();
for i in pos..bytes.len() - 3 {
for i in pos..bytes.len() {
if i + 3 > bytes.len() {
break;
}
if bytes[i..i + 3]
.iter()
.all(|c| is_valid_plaintext_char(*c, allow_whitespace))