Avoid Reader::mark() & Reader::get_input_between_marks().
This API is a little awkward and doesn't statically guarantee correctness (e.g. the start is before the end, or that the marks are for the same `Input`) as much as we would like. This is a step toward getting rid of it.
This commit is contained in:
parent
35538d887c
commit
13a62c8b02
22
src/der.rs
22
src/der.rs
@ -130,17 +130,17 @@ fn nonnegative_integer<'a>(input: &mut untrusted::Reader<'a>, min_value: u8)
|
||||
return Ok(value);
|
||||
}
|
||||
|
||||
let after_leading_zero = input.mark();
|
||||
let second_byte = try!(input.read_byte());
|
||||
if (second_byte & 0x80) == 0 {
|
||||
// A leading zero is only allowed when the value's high bit
|
||||
// is set.
|
||||
return Err(error::Unspecified);
|
||||
}
|
||||
|
||||
let _ = input.skip_to_end();
|
||||
let r = try!(input.get_input_between_marks(after_leading_zero,
|
||||
input.mark()));
|
||||
let r = input.skip_to_end();
|
||||
try!(r.read_all(error::Unspecified, |input| {
|
||||
let second_byte = try!(input.read_byte());
|
||||
if (second_byte & 0x80) == 0 {
|
||||
// A leading zero is only allowed when the value's high bit
|
||||
// is set.
|
||||
return Err(error::Unspecified);
|
||||
}
|
||||
let _ = input.skip_to_end();
|
||||
Ok(())
|
||||
}));
|
||||
try!(check_minimum(r, min_value));
|
||||
return Ok(r);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user