When parts read from underlying reader include valid padding the
reader accepts the input even if there’s more data to follow. In this
example the reader produces string AA==AA==AA== which should result
in an error but instead generates three zero bytes.
struct Foo(usize);
impl std::io::Read for Foo {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
if self.0 == 0 {
return Ok(0);
}
self.0 -= 1;
buf[..4].copy_from_slice(b"AA==");
Ok(4)
}
}
fn main() {
use std::io::Read;
use base64::engine::general_purpose::STANDARD;
let mut decoder = base64::read::DecoderReader::new(Foo(3), &STANDARD);
let mut vec = Vec::new();
let res = decoder.read_to_end(&mut vec);
print!("{res:?} {vec:?}");
}
When parts read from underlying reader include valid padding the reader accepts the input even if there’s more data to follow. In this example the reader produces string
AA==AA==AA==
which should result in an error but instead generates three zero bytes.