From 10ada483e528fc33ba94bd36036dcf3a7e708e18 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Wed, 1 Aug 2018 18:34:44 +0200 Subject: [PATCH] Memory error in backend transaction revert --- CHANGELOG.md | 1 + apps/backend/backend_plugin.c | 4 ++-- lib/src/clixon_plugin.c | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86621a90..a80300f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Added -l option for clixon_backend for directing syslog to stderr or stdout if running in foreground ### Corrected Bugs +* Memory error in backend transaction revert * Set dir /www-data with www-data as owner, see https://github.com/clicon/clixon/issues/37 ### Known issues diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c index e193b876..b11e9b67 100644 --- a/apps/backend/backend_plugin.c +++ b/apps/backend/backend_plugin.c @@ -100,7 +100,7 @@ clixon_plugin_reset(clicon_handle h, if ((resetfn = cp->cp_api.ca_reset) == NULL) continue; if ((retval = resetfn(h, db)) < 0) { - clicon_debug(1, "plugin_start() failed\n"); + clicon_debug(1, "plugin_start() failed"); return -1; } break; @@ -357,7 +357,7 @@ plugin_transaction_revert(clicon_handle h, while ((cp = clixon_plugin_each_revert(h, cp, nr)) != NULL) { if ((fn = cp->cp_api.ca_trans_commit) == NULL) continue; - if ((retval = fn(h, (transaction_data)td)) < 0){ + if ((retval = fn(h, (transaction_data)&tr)) < 0){ clicon_log(LOG_NOTICE, "%s: Plugin '%s' trans_commit revert callback failed", __FUNCTION__, cp->cp_name); break; diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index 5e17cd1e..7710ae80 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -130,8 +130,10 @@ clixon_plugin_each_revert(clicon_handle h, clixon_plugin *cp = NULL; clixon_plugin *cpnext = NULL; - if (cpprev == NULL) - cpnext = &_clixon_plugins[nr-1]; + if (cpprev == NULL){ + if (nr>0) + cpnext = &_clixon_plugins[nr-1]; + } else{ for (i = nr-1; i >= 0; i--) { cp = &_clixon_plugins[i]; @@ -320,7 +322,7 @@ clixon_plugin_start(clicon_handle h, continue; // optind = 0; if (startfn(h, argc, argv) < 0) { - clicon_debug(1, "plugin_start() failed\n"); + clicon_debug(1, "plugin_start() failed"); return -1; } } @@ -343,7 +345,7 @@ clixon_plugin_exit(clicon_handle h) if ((exitfn = cp->cp_api.ca_exit) == NULL) continue; if (exitfn(h) < 0) { - clicon_debug(1, "plugin_exit() failed\n"); + clicon_debug(1, "plugin_exit() failed"); return -1; } if (dlclose(cp->cp_handle) != 0) { @@ -385,7 +387,7 @@ clixon_plugin_auth(clicon_handle h, if ((authfn = cp->cp_api.ca_auth) == NULL) continue; if ((retval = authfn(h, arg)) < 0) { - clicon_debug(1, "plugin_auth() failed\n"); + clicon_debug(1, "plugin_auth() failed"); return -1; } break;