]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pgsql: check for eol when parsing response 10856/head
authorJuliana Fajardini <jufajardini@oisf.net>
Sat, 13 Apr 2024 02:12:03 +0000 (23:12 -0300)
committerVictor Julien <victor@inliniac.net>
Tue, 16 Apr 2024 06:00:40 +0000 (08:00 +0200)
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

index 5c46008c379c1ef5eae32d0c569820b5dabaa3b2..eda9d484856d513e9a33ab699a3a05fdc78d3f6d 100644 (file)
@@ -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);