melib: tighten bounds check in email/parser.rs

embed
Manos Pitsidianakis 2019-07-31 13:30:28 +03:00
parent d73069bc80
commit 391e5b5d13
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 6 additions and 6 deletions

View File

@ -143,19 +143,19 @@ fn header_with_val(input: &[u8]) -> IResult<&[u8], (&[u8], &[u8])> {
if name.is_empty() {
return IResult::Error(error_code!(ErrorKind::Custom(43)));
}
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Error(error_code!(ErrorKind::Custom(43)));
}
if input[ptr] == b'\n' {
ptr += 1;
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Error(error_code!(ErrorKind::Custom(43)));
}
}
while input[ptr] == b' ' || input[ptr] == b'\t' {
ptr += 1;
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Error(error_code!(ErrorKind::Custom(43)));
}
}
@ -186,19 +186,19 @@ fn header_without_val(input: &[u8]) -> IResult<&[u8], (&[u8], &[u8])> {
}
if input[ptr] == b':' {
ptr += 1;
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Incomplete(Needed::Unknown);
}
}
while input[ptr] == b' ' {
ptr += 1;
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Incomplete(Needed::Unknown);
}
}
if input[ptr..].starts_with(b"\n") {
ptr += 1;
if ptr > input.len() {
if ptr >= input.len() {
return IResult::Incomplete(Needed::Unknown);
}
if input[ptr] != b' ' && input[ptr] != b'\t' {