We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c72166d commit 7959229Copy full SHA for 7959229
src/decoder/mod.rs
@@ -42,6 +42,11 @@ use serde::de::Deserialize;
42
fn read_string<R: Read + ?Sized>(reader: &mut R, utf8_lossy: bool) -> DecoderResult<String> {
43
let len = reader.read_i32::<LittleEndian>()?;
44
45
+ // UTF-8 String must have at least 1 byte (the last 0x00).
46
+ if len < 1 {
47
+ return Err(DecoderError::InvalidLength(len as usize, format!("invalid length {} for UTF-8 string", len)));
48
+ }
49
+
50
let s = if utf8_lossy {
51
let mut buf = Vec::with_capacity(len as usize - 1);
52
reader.take(len as u64 - 1).read_to_end(&mut buf)?;
0 commit comments