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
pull/6854/head
Juliana Fajardini 3 years ago committed by Victor Julien
parent 59ac1fe277
commit 0bf1227f0f

@ -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)?;

@ -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;
}
}

Loading…
Cancel
Save