/// 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;
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;
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) {
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)
}
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
-/* 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
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);
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);