Skip to content

Commit a03f9f3

Browse files
authored
Revert "base64ct: reject zero-length decode requests (#1387)" (#1714)
This reverts commit a375cbf. This was a breaking change which is causing issues in the `der` crate. See #1711
1 parent 4d01d6a commit a03f9f3

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

base64ct/src/decoder.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,8 @@ impl<'i, E: Encoding> Decoder<'i, E> {
102102
///
103103
/// # Returns
104104
/// - `Ok(bytes)` if the expected amount of data was read
105-
/// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read, or
106-
/// if the output buffer has a length of 0
105+
/// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read
107106
pub fn decode<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8], Error> {
108-
if out.is_empty() {
109-
return Err(InvalidLength);
110-
}
111-
112107
if self.is_finished() {
113108
return Err(InvalidLength);
114109
}
@@ -551,8 +546,6 @@ impl<'i> Iterator for LineReader<'i> {
551546
mod tests {
552547
use crate::{Base64, Base64Unpadded, Decoder, alphabet::Alphabet, test_vectors::*};
553548

554-
#[cfg(feature = "std")]
555-
use crate::Error::InvalidLength;
556549
#[cfg(feature = "std")]
557550
use {alloc::vec::Vec, std::io::Read};
558551

@@ -598,16 +591,6 @@ mod tests {
598591
assert_eq!(buf.as_slice(), MULTILINE_PADDED_BIN);
599592
}
600593

601-
#[cfg(feature = "std")]
602-
#[test]
603-
fn reject_empty_read() {
604-
let mut decoder = Decoder::<Base64>::new(b"AAAA").unwrap();
605-
606-
let mut buf: Vec<u8> = vec![];
607-
608-
assert_eq!(decoder.decode(&mut buf), Err(InvalidLength));
609-
}
610-
611594
/// Core functionality of a decoding test
612595
#[allow(clippy::arithmetic_side_effects)]
613596
fn decode_test<'a, F, V>(expected: &[u8], f: F)

0 commit comments

Comments
 (0)