Skip to content

Commit

Permalink
pgsql: don't return error for parsing errors
Browse files Browse the repository at this point in the history
This allows the app-proto to continue onto parsing next PDUs, if
possible.

Task #5524
  • Loading branch information
jufajardini committed Feb 7, 2025
1 parent aae0451 commit c7b6461
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions rust/src/pgsql/pgsql.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2022-2024 Open Information Security Foundation
/* Copyright (C) 2022-2025 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
Expand All @@ -25,6 +25,7 @@ use crate::conf::*;
use crate::core::{AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, *};
use crate::direction::Direction;
use crate::flow::Flow;
use nom7::error::{Error, ErrorKind};
use nom7::{Err, IResult};
use std;
use std::collections::VecDeque;
Expand Down Expand Up @@ -397,8 +398,17 @@ impl PgsqlState {
);
return AppLayerResult::incomplete(consumed as u32, needed_estimation as u32);
}
Err(Err::Error(Error{code:ErrorKind::Verify, ..})) => {
SCLogDebug!("PgsqlEvent::InvalidLength");
AppLayerResult::ok();
}
Err(Err::Error(Error{code:ErrorKind::Switch, ..})) => {
SCLogDebug!("PgsqlEvent::MalformedData");
return AppLayerResult::ok();
}
Err(_) => {
return AppLayerResult::err();
SCLogDebug!("Error while parsing PGSQL request");
return AppLayerResult::ok();
}
}
}
Expand Down Expand Up @@ -571,9 +581,17 @@ impl PgsqlState {
);
return AppLayerResult::incomplete(consumed as u32, needed_estimation as u32);
}
Err(Err::Error(Error{code:ErrorKind::Verify, ..})) => {
SCLogDebug!("PgsqlEvent::InvalidLength");
return AppLayerResult::ok();
}
Err(Err::Error(Error{code:ErrorKind::Switch, ..})) => {
SCLogDebug!("PgsqlEvent::MalformedData");
return AppLayerResult::ok();
}
Err(_) => {
SCLogDebug!("Error while parsing PostgreSQL response");
return AppLayerResult::err();
SCLogDebug!("Error while parsing PGSQL response");
return AppLayerResult::ok();
}
}
}
Expand Down

0 comments on commit c7b6461

Please sign in to comment.