diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2019-01-15 14:20:14 +0100 |
---|---|---|
committer | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2019-01-16 13:19:31 +0000 |
commit | f8531f98503e72238253d4faff634293ad4d1941 (patch) | |
tree | 0ea2b270211791dfbf36900e45463e62db047701 /ctl-lib | |
parent | f1c3b6be4e006b97940c480ee416eb461ec36e2c (diff) |
ctl-action: fixed the calculation of the number of actionsicefish_8.99.5icefish_8.99.4icefish_8.99.3icefish_8.99.2icefish_8.99.1icefish/8.99.5icefish/8.99.4icefish/8.99.3icefish/8.99.2icefish/8.99.1halibut_8.0.6halibut_8.0.5halibut_8.0.4halibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut_7.99.3halibut_7.99.2halibut_7.99.1halibut_7.90.0halibut/8.0.6halibut/8.0.5halibut/8.0.4halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.0halibut/7.99.3halibut/7.99.2halibut/7.99.1halibut/7.90.0guppy_6.99.4guppy/6.99.48.99.58.99.48.99.38.99.28.99.18.0.68.0.58.0.48.0.38.0.28.0.18.0.07.99.37.99.27.99.17.90.06.99.4halibut
When adding actions to a section, the number of existing
actions was badly calculated, leading to access to
uninitialized memory when walking through
the list later, because there was a missing null
action at the end.
Change-Id: I18390463cbe94d1c8788add33f99814404c59760
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r-- | ctl-lib/ctl-action.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c index 0bd9c7b..2b0813b 100644 --- a/ctl-lib/ctl-action.c +++ b/ctl-lib/ctl-action.c @@ -373,13 +373,16 @@ int AddActionsToSection(AFB_ApiT apiHandle, CtlSectionT *section, json_object *a CtlActionT *savedActions = section->actions; CtlActionT *newActions = ActionConfig(apiHandle, actionsJ, exportApi); - while(savedActions[actionsNb].uid) + while(savedActions[idx++].uid) { actionsNb++; - while(newActions[actionsNb].uid) + } + idx = 0; + while(newActions[idx++].uid) { actionsNb++; - + } + /* Allocate one more, NULL uid marks the end of the table */ actions = calloc(actionsNb + 1, sizeof(CtlActionT)); - + idx = 0; while(savedActions[idx].uid) { actions[idx] = savedActions[idx]; idx++; |