From d64413f6cd700d0466ff421fabb40ae7b4da3939 Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Wed, 24 Aug 2022 23:13:49 +0200 Subject: [PATCH] Log "NULL" for nullptr-bound properties instead of dereferencing Fixes the issue where pdnsutil would segfault when query logging is enabled, and would leave the db unmodified. Surprisingly, the segfault only happened on FreeBSD. Fixes #11731 (cherry picked from commit fd4fd2dae2f29f668b7ad0645c112b12854ab834) backport of #11882 --- modules/gpgsqlbackend/spgsql.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/gpgsqlbackend/spgsql.cc b/modules/gpgsqlbackend/spgsql.cc index 996d72dbc7..823d38dd3e 100644 --- a/modules/gpgsqlbackend/spgsql.cc +++ b/modules/gpgsqlbackend/spgsql.cc @@ -85,7 +85,13 @@ public: if (i != 0) { log_message << ", "; } - log_message << "$" << (i + 1) << " = '" << paramValues[i] << "'"; + log_message << "$" << (i + 1) << " = "; + if (paramValues[i] == nullptr) { + log_message << "NULL"; + } + else { + log_message << "'" << paramValues[i] << "'"; + } } g_log << Logger::Warning << log_message.str() << endl; } -- 2.47.3