Method
read_cstring_with_length
(&self, cursor: &mut Cursor<&[u8]>, max_length: usize)
Source from the content-addressed store, hash-verified
| 363 | } |
| 364 | |
| 365 | async fn read_cstring_with_length(&self, cursor: &mut Cursor<&[u8]>, max_length: usize) -> Result<String, ParseError> { |
| 366 | let mut bytes = Vec::new(); |
| 367 | let limited_length = max_length.min(self.max_string_length); |
| 368 | |
| 369 | for _ in 0..limited_length { |
| 370 | let byte = cursor.read_u8()?; |
| 371 | if byte == 0 { |
| 372 | break; |
| 373 | } |
| 374 | bytes.push(byte); |
| 375 | } |
| 376 | |
| 377 | String::from_utf8(bytes).map_err(|_| ParseError::InvalidEncoding) |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // Simplified message types for fuzzing |
Tested by
no test coverage detected