fix substraction overflow
This commit is contained in:
parent
eae4a0443a
commit
7dc139737c
2 changed files with 5 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
name = "nettext"
|
name = "nettext"
|
||||||
description = "A text-based data format for cryptographic network protocols"
|
description = "A text-based data format for cryptographic network protocols"
|
||||||
authors = ["Alex Auvolat <alex@adnab.me>"]
|
authors = ["Alex Auvolat <alex@adnab.me>"]
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -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
|
// We stop at the first position where we find three consecutive
|
||||||
// characters to encode as-is
|
// characters to encode as-is
|
||||||
let mut b64end = bytes.len();
|
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]
|
if bytes[i..i + 3]
|
||||||
.iter()
|
.iter()
|
||||||
.all(|c| is_valid_plaintext_char(*c, allow_whitespace))
|
.all(|c| is_valid_plaintext_char(*c, allow_whitespace))
|
||||||
|
|
Loading…
Reference in a new issue