From 35a3b0a1a3230e465b3a434603cd6608b3350121 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 28 Sep 2023 10:01:09 +0200 Subject: schema: fix bug when og_dbi_open cannot open a connection When og_dbi_open cannot open a connection during schema update, then ogServer crashes. og_dbi_open returns NULL when it cannot open a DB connection. Do not use dbi variable if og_dbi_open is unable to open a DB connection. Add syslog message when database schema couldn't be updated. --- src/schema.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/schema.c') diff --git a/src/schema.c b/src/schema.c index 56d52ba..d31046e 100644 --- a/src/schema.c +++ b/src/schema.c @@ -255,13 +255,11 @@ int og_dbi_schema_update(void) { int version, i, err; struct og_dbi *dbi; - const char *msglog; dbi = og_dbi_open(&ogconfig.db); if (!dbi) { - dbi_conn_error(dbi->conn, &msglog); - syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", - __func__, __LINE__, msglog); + syslog(LOG_ERR, "cannot open a database connection (%s:%d)\n", + __func__, __LINE__); return -1; } -- cgit v1.2.3-18-g5258