From 0bf1227f0f061930cfdb751db5f055f20fb819a7 Mon Sep 17 00:00:00 2001 From: Juliana Fajardini Date: Fri, 21 Jan 2022 11:47:15 +0000 Subject: [PATCH] pgsql: fix defect found by coverity 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 | 2 +- src/output-json-pgsql.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/src/pgsql/logger.rs b/rust/src/pgsql/logger.rs index cfe97f35d9..f0b0d57947 100644 --- a/rust/src/pgsql/logger.rs +++ b/rust/src/pgsql/logger.rs @@ -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)?; diff --git a/src/output-json-pgsql.c b/src/output-json-pgsql.c index b2669270eb..0ab87d1760 100644 --- a/src/output-json-pgsql.c +++ b/src/output-json-pgsql.c @@ -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; } }