libafl_nyx: Add bounds check for Nyx input buffer (#1963)

This commit is contained in:
Maurice 2024-03-23 18:31:07 +01:00 committed by GitHub
parent a0d4a5b240
commit f448b6fb24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,6 +55,16 @@ where
let bytes = input.target_bytes(); let bytes = input.target_bytes();
let buffer = bytes.as_slice(); let buffer = bytes.as_slice();
if buffer.len() > self.helper.nyx_process.input_buffer_size() {
return Err(Error::illegal_state(format!(
"Input does not fit in the Nyx input buffer.\
You may want to increase the Nyx input buffer size: {} > {}",
buffer.len(),
self.helper.nyx_process.input_buffer_size()
)));
}
let size = u32::try_from(buffer.len()) let size = u32::try_from(buffer.len())
.map_err(|_| Error::unsupported("Inputs larger than 4GB are not supported"))?; .map_err(|_| Error::unsupported("Inputs larger than 4GB are not supported"))?;