From ce1556cefd79ff53e3eb2e2542718c901958f183 Mon Sep 17 00:00:00 2001 From: Juliana Fajardini Date: Fri, 12 Apr 2024 23:12:03 -0300 Subject: [PATCH] pgsql: check for eol when parsing response It was brought to my attention by GLongo that Pgsql parser handled eof diffrently for requests and responses, and apparently there isn't a good reason for such a difference therefore, apply same logic used for rs_pgsql_parse_request for checking for eof when parsing a response. --- rust/src/pgsql/pgsql.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rust/src/pgsql/pgsql.rs b/rust/src/pgsql/pgsql.rs index 5c46008c37..eda9d48485 100644 --- a/rust/src/pgsql/pgsql.rs +++ b/rust/src/pgsql/pgsql.rs @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Open Information Security Foundation +/* Copyright (C) 2022-2024 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 @@ -661,7 +661,13 @@ pub unsafe extern "C" fn rs_pgsql_parse_response( flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void, stream_slice: StreamSlice, _data: *const std::os::raw::c_void, ) -> AppLayerResult { - let _eof = AppLayerParserStateIssetFlag(pstate, APP_LAYER_PARSER_EOF_TC) > 0; + if stream_slice.is_empty() { + if AppLayerParserStateIssetFlag(pstate, APP_LAYER_PARSER_EOF_TC) > 0 { + return AppLayerResult::ok(); + } else { + return AppLayerResult::err(); + } + } let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState);