diff options
author | Roman Rakus <rrakus@redhat.com> | 2013-09-04 15:25:02 +0200 |
---|---|---|
committer | Roman Rakus <rrakus@redhat.com> | 2013-09-04 16:45:15 +0200 |
commit | 23c7f0b6a4dbd86b6e80ba095110742ef79e7a28 (patch) | |
tree | f70e4ca7d22ab0f564f87913476267d382fe9c71 /src/account/LMI_GroupProvider.c | |
parent | 66fee3cfd9736b860872f0e6a757f11404015193 (diff) | |
download | openlmi-providers-23c7f0b6a4dbd86b6e80ba095110742ef79e7a28.tar.gz openlmi-providers-23c7f0b6a4dbd86b6e80ba095110742ef79e7a28.tar.xz openlmi-providers-23c7f0b6a4dbd86b6e80ba095110742ef79e7a28.zip |
Account: Fix memory corruption
There was false assumption that lu_end doesn't free error messages.
The code is restructured to copy error message to temporary string
holder, which is freed after and error message is correctly returned,
all in one place.
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src/account/LMI_GroupProvider.c')
-rw-r--r-- | src/account/LMI_GroupProvider.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/account/LMI_GroupProvider.c b/src/account/LMI_GroupProvider.c index d3263f4..0dd548d 100644 --- a/src/account/LMI_GroupProvider.c +++ b/src/account/LMI_GroupProvider.c @@ -146,6 +146,8 @@ static CMPIStatus LMI_GroupDeleteInstance( struct lu_context *luc = NULL; struct lu_error *error = NULL; struct lu_ent *lue = NULL; + CMPIrc rc = CMPI_RC_OK; + char *errmsg = NULL; LMI_Group_InitFromObjectPath(&lg, _cb, cop); name = lg.Name.chars; @@ -160,23 +162,30 @@ static CMPIStatus LMI_GroupDeleteInstance( lue = lu_ent_new(); if (!lu_group_lookup_name(luc, name, lue, &error)) { /* Group not found */ - lu_ent_free(lue); - lu_end(luc); - KReturn2(_cb, ERR_NOT_FOUND, "Non existing group: %s\n", name); + asprintf(&errmsg, "Non existing group: %s\n", name); + rc = CMPI_RC_ERR_NOT_FOUND; + goto fail; } if (!lu_group_delete(luc, lue, &error)) { - lu_ent_free(lue); - lu_end(luc); - KReturn2(_cb, ERR_FAILED, "Group %s could not be deleted: %s\n", name, - lu_strerror(error)); + asprintf(&errmsg, "Group %s could not be deleted: %s\n", name, + lu_strerror(error)); + rc = CMPI_RC_ERR_FAILED; + goto fail; } +fail: lu_ent_free(lue); lu_end(luc); - CMReturn(CMPI_RC_OK); + if (errmsg) { + CMPIString *errstr = CMNewString(_cb, errmsg, NULL); + free(errmsg); + CMReturnWithString(rc, errstr); + } else { + CMReturn(rc); + } } static CMPIStatus LMI_GroupExecQuery( |