about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorkaffeekanne <kaffeekanne@users.noreply.github.com>2021-02-15 08:50:43 +0100
committerkaffeekanne <kaffeekanne@users.noreply.github.com>2021-02-15 15:58:35 +0100
commit49dc9c5755bda6e395c85faada3989f024fda202 (patch)
tree46e2c23587d28ea1a4c04018aef7ea7eb6896b0f
parent79fbd403a7c1fdecc4e9062e3ae60cab7209da8e (diff)
downloadprofani-tty-49dc9c5755bda6e395c85faada3989f024fda202.tar.gz
Calm OpenBSD syslog
On every write to `chatlog.db` syslog throws
```
profanity: vfprintf %s NULL in "INSERT INTO `ChatLogs` (`from_jid`,
`from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`,
`stanza_id`, `archive_id`, `replace_id`, `type`, `encryption`) SELECT
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' WHERE
NOT EXISTS (SELECT 1 FROM `ChatLogs` WHERE `archive_id` = '%s')"
```
in `/var/log/messages`. Checking for `NULL` except in the fields the DB
is expected to throw errors for, satisfies OpenBSDs security measures
-rw-r--r--src/database.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c
index 5ea981f8..4919dc3d 100644
--- a/src/database.c
+++ b/src/database.c
@@ -334,14 +334,14 @@ _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Ji
                  from_jid->resourcepart ? from_jid->resourcepart : "",
                  to_jid->barejid,
                  to_jid->resourcepart ? to_jid->resourcepart : "",
-                 escaped_message,
-                 date_fmt,
+                 escaped_message ? escaped_message : "",
+                 date_fmt ? date_fmt : "",
                  message->id ? message->id : "",
                  message->stanzaid ? message->stanzaid : "",
                  message->replace_id ? message->replace_id : "",
-                 type,
-                 enc,
-                 message->stanzaid)
+                 type ? type : "",
+                 enc ? enc : "",
+                 message->stanzaid ? message->stanzaid : "")
         == -1) {
         log_error("log_database_add(): SQL query. could not allocate memory");
         return;