smb: update return type of GAP handling

pull/4691/head
Victor Julien 5 years ago
parent 4bf87d30e4
commit 5cd9cfb5a0

@ -1752,7 +1752,7 @@ impl SMBState {
/// handle a gap in the TOSERVER direction
/// returns: 0 ok, 1 unrecoverable error
pub fn parse_tcp_data_ts_gap(&mut self, gap_size: u32) -> u32 {
pub fn parse_tcp_data_ts_gap(&mut self, gap_size: u32) -> AppLayerResult {
let consumed = self.handle_skip(STREAM_TOSERVER, gap_size);
if consumed < gap_size {
let new_gap_size = gap_size - consumed;
@ -1762,18 +1762,18 @@ impl SMBState {
if consumed2 > new_gap_size {
SCLogDebug!("consumed more than GAP size: {} > {}", consumed2, new_gap_size);
self.set_event(SMBEvent::InternalError);
return 1;
return AppLayerResult::err();
}
}
SCLogDebug!("GAP of size {} in toserver direction", gap_size);
self.ts_ssn_gap = true;
self.ts_gap = true;
return 0
return AppLayerResult::ok();
}
/// handle a gap in the TOCLIENT direction
/// returns: 0 ok, 1 unrecoverable error
pub fn parse_tcp_data_tc_gap(&mut self, gap_size: u32) -> u32 {
pub fn parse_tcp_data_tc_gap(&mut self, gap_size: u32) -> AppLayerResult {
let consumed = self.handle_skip(STREAM_TOCLIENT, gap_size);
if consumed < gap_size {
let new_gap_size = gap_size - consumed;
@ -1783,13 +1783,13 @@ impl SMBState {
if consumed2 > new_gap_size {
SCLogDebug!("consumed more than GAP size: {} > {}", consumed2, new_gap_size);
self.set_event(SMBEvent::InternalError);
return 1;
return AppLayerResult::err();
}
}
SCLogDebug!("GAP of size {} in toclient direction", gap_size);
self.tc_ssn_gap = true;
self.tc_gap = true;
return 0
return AppLayerResult::ok();
}
pub fn trunc_ts(&mut self) {
@ -1862,12 +1862,9 @@ pub extern "C" fn rs_smb_parse_request_tcp(flow: &mut Flow,
pub extern "C" fn rs_smb_parse_request_tcp_gap(
state: &mut SMBState,
input_len: u32)
-> i8
-> AppLayerResult
{
if state.parse_tcp_data_ts_gap(input_len as u32) == 0 {
return 0;
}
return -1;
state.parse_tcp_data_ts_gap(input_len as u32)
}
@ -1897,12 +1894,9 @@ pub extern "C" fn rs_smb_parse_response_tcp(flow: &mut Flow,
pub extern "C" fn rs_smb_parse_response_tcp_gap(
state: &mut SMBState,
input_len: u32)
-> i8
-> AppLayerResult
{
if state.parse_tcp_data_tc_gap(input_len as u32) == 0 {
return 0;
}
return -1;
state.parse_tcp_data_tc_gap(input_len as u32)
}
// probing parser

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Open Information Security Foundation
/* Copyright (C) 2017-2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -39,12 +39,9 @@ static AppLayerResult SMBTCPParseRequest(Flow *f, void *state,
rs_smb_setfileflags(0, state, file_flags|FILE_USE_DETECT);
if (input == NULL && input_len > 0) {
int res = rs_smb_parse_request_tcp_gap(state, input_len);
SCLogDebug("SMB request GAP of %u bytes, retval %d", input_len, res);
if (res != 0) {
SCReturnStruct(APP_LAYER_ERROR);
}
SCReturnStruct(APP_LAYER_OK);
AppLayerResult res = rs_smb_parse_request_tcp_gap(state, input_len);
SCLogDebug("SMB request GAP of %u bytes, retval %d", input_len, res.status);
SCReturnStruct(res);
} else {
AppLayerResult res = rs_smb_parse_request_tcp(f, state, pstate,
input, input_len, local_data, flags);
@ -64,13 +61,9 @@ static AppLayerResult SMBTCPParseResponse(Flow *f, void *state,
SCLogDebug("SMBTCPParseResponse %p/%u", input, input_len);
if (input == NULL && input_len > 0) {
int res = rs_smb_parse_response_tcp_gap(state, input_len);
if (res != 0) {
SCLogDebug("SMB response%s of %u bytes, retval %d",
(input == NULL && input_len > 0) ? " is GAP" : "", input_len, res);
SCReturnStruct(APP_LAYER_ERROR);
}
SCReturnStruct(APP_LAYER_OK);
AppLayerResult res = rs_smb_parse_response_tcp_gap(state, input_len);
SCLogDebug("SMB response GAP of %u bytes, retval %d", input_len, res.status);
SCReturnStruct(res);
} else {
AppLayerResult res = rs_smb_parse_response_tcp(f, state, pstate,
input, input_len, local_data, flags);

Loading…
Cancel
Save