diff --git a/rust/src/ftp/mod.rs b/rust/src/ftp/mod.rs index aae5ff4afe..a206aa2f35 100644 --- a/rust/src/ftp/mod.rs +++ b/rust/src/ftp/mod.rs @@ -88,6 +88,9 @@ pub fn ftp_pasv_response(i: &[u8]) -> IResult<&[u8], u16> { #[no_mangle] pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 { + if input.is_null() { + return 0; + } let buf = build_slice!(input, len as usize); match ftp_active_port(buf) { Ok((_, dport)) => { @@ -105,7 +108,10 @@ pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 { #[no_mangle] pub unsafe extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 { - let buf = std::slice::from_raw_parts(input, len as usize); + if input.is_null() { + return 0; + } + let buf = build_slice!(input, len as usize); match ftp_pasv_response(buf) { Ok((_, dport)) => { return dport; @@ -147,6 +153,9 @@ pub fn ftp_active_eprt(i: &[u8]) -> IResult<&[u8], u16> { #[no_mangle] pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 { + if input.is_null() { + return 0; + } let buf = build_slice!(input, len as usize); match ftp_active_eprt(buf) { Ok((_, dport)) => { @@ -163,7 +172,10 @@ pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 { } #[no_mangle] pub unsafe extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 { - let buf = std::slice::from_raw_parts(input, len as usize); + if input.is_null() { + return 0; + } + let buf = build_slice!(input, len as usize); match ftp_epsv_response(buf) { Ok((_, dport)) => { return dport;