Skip to content

Commit

Permalink
base64
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed May 9, 2024
1 parent 9438e82 commit d2f20e9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/cli/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub enum InputFormat {
StreamBase64,
StreamFramed,
VarArray,
VarArrayBase64,
}

impl Default for InputFormat {
Expand Down Expand Up @@ -121,6 +122,23 @@ macro_rules! run_x {
Err(crate::$m::Error::Invalid)?;
}
}
InputFormat::VarArrayBase64 => {
use crate::$m::ReadXdr;
let mut dec = crate::$m::Limited::new(
base64::read::DecoderReader::new(&mut f, base64::STANDARD),
crate::$m::Limits::none(),
);
let len = u32::read_xdr(&mut dec)?;
for _ in 0..len {
let t = crate::$m::Type::read_xdr(r#type, &mut dec)?;
self.out(&t)?;
}
// Check that any further reads, such as this read of one byte, read no
// data, indicating EOF. If a byte is read the data is invalid.
if dec.read(&mut [0u8; 1])? != 0 {
Err(crate::$m::Error::Invalid)?;
}
}
};
}
Ok(())
Expand Down

0 comments on commit d2f20e9

Please sign in to comment.