From d6284b613835ddd1b250688cb7fe657119490820 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 15 Jul 2024 10:09:02 +0200 Subject: rest: add dbi query checks in og_set_client_mode Check if the the execution of the main SQL query is not successfull. --- src/rest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rest.c b/src/rest.c index 2b8fbaf..8191648 100644 --- a/src/rest.c +++ b/src/rest.c @@ -1337,6 +1337,14 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *mac, "WHERE ordenadores.mac='%s'", getenv("LANG"), mac); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", + __func__, __LINE__, msglog); + og_dbi_close(dbi); + return -1; + } + if (dbi_result_get_numrows(result) != 1) { dbi_conn_error(dbi->conn, &msglog); syslog(LOG_ERR, "failed to query database (%s:%d) %s\n", -- cgit v1.2.3-18-g5258