rust/ftp: handle NULL inputs

Completes Ticket 7013
pull/12259/head
Philippe Antoine 2 years ago committed by Victor Julien
parent 38d7900fa9
commit e62c7d733b

@ -88,6 +88,9 @@ pub fn ftp_pasv_response(i: &[u8]) -> IResult<&[u8], u16> {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 { 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); let buf = build_slice!(input, len as usize);
match ftp_active_port(buf) { match ftp_active_port(buf) {
Ok((_, dport)) => { Ok((_, dport)) => {
@ -105,7 +108,10 @@ pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 { 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) { match ftp_pasv_response(buf) {
Ok((_, dport)) => { Ok((_, dport)) => {
return dport; return dport;
@ -147,6 +153,9 @@ pub fn ftp_active_eprt(i: &[u8]) -> IResult<&[u8], u16> {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 { 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); let buf = build_slice!(input, len as usize);
match ftp_active_eprt(buf) { match ftp_active_eprt(buf) {
Ok((_, dport)) => { Ok((_, dport)) => {
@ -163,7 +172,10 @@ pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 {
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 { 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) { match ftp_epsv_response(buf) {
Ok((_, dport)) => { Ok((_, dport)) => {
return dport; return dport;

Loading…
Cancel
Save