]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pgsql: fix defect found by coverity 6854/head
authorJuliana Fajardini <jufajardini@gmail.com>
Fri, 21 Jan 2022 11:47:15 +0000 (11:47 +0000)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Jan 2022 10:32:19 +0000 (11:32 +0100)
Pgsql was using bitwise operations to assign password output config to
its context flags, but mixing that with logic negation of the default
value, resulting in the expressions having a constant value as result.

Bug: #5007

rust/src/pgsql/logger.rs
src/output-json-pgsql.c

index cfe97f35d9b993f34048209564e838f9c2277adc..f0b0d579476157b333e8f77a1884fb9c563a827f 100644 (file)
@@ -24,7 +24,7 @@ use crate::pgsql::parser::*;
 use crate::pgsql::pgsql::*;
 use std;
 
-pub const PGSQL_LOG_PASSWORDS: u32 = BIT_U32!(1);
+pub const PGSQL_LOG_PASSWORDS: u32 = BIT_U32!(0);
 
 fn log_pgsql(tx: &PgsqlTransaction, flags: u32, js: &mut JsonBuilder) -> Result<(), JsonError> {
     js.set_uint("tx_id", tx.tx_id)?;
index b2669270ebc14e96a51aeb178916dcbae495586b..0ab87d17605b700085969205788b826213d02afa 100644 (file)
@@ -47,7 +47,7 @@
 #include "output-json-pgsql.h"
 #include "rust.h"
 
-#define PGSQL_LOG_PASSWORDS BIT_U32(1)
+#define PGSQL_LOG_PASSWORDS BIT_U32(0)
 
 typedef struct OutputPgsqlCtx_ {
     uint32_t flags;
@@ -103,10 +103,10 @@ static void JsonPgsqlLogParseConfig(ConfNode *conf, OutputPgsqlCtx *pgsqllog_ctx
         if (ConfValIsTrue(query)) {
             pgsqllog_ctx->flags |= PGSQL_LOG_PASSWORDS;
         } else {
-            pgsqllog_ctx->flags &= !PGSQL_LOG_PASSWORDS;
+            pgsqllog_ctx->flags &= ~PGSQL_LOG_PASSWORDS;
         }
     } else {
-        pgsqllog_ctx->flags &= !PGSQL_LOG_PASSWORDS;
+        pgsqllog_ctx->flags &= ~PGSQL_LOG_PASSWORDS;
     }
 }