summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-11-29 11:25:14 -0500
committerRobbie Harwood <rharwood@redhat.com>2015-11-30 12:59:06 -0500
commit79e92a939784d248390cc2357387e667b7c97d9c (patch)
treea2bcc0e3791d446db93456437901f1a4a910bc0c
parent439cd2ff3bc7b2ab6374104f12c0dba5870f0381 (diff)
downloadgss-proxy-79e92a939784d248390cc2357387e667b7c97d9c.tar.gz
gss-proxy-79e92a939784d248390cc2357387e667b7c97d9c.tar.xz
gss-proxy-79e92a939784d248390cc2357387e667b7c97d9c.zip
Improve code in gp_export_gssx_cred()
Remove dead code, and set length only if allocation was successful. Also resolve valgrind complaints about uninitialized memory. Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com>
-rw-r--r--proxy/src/gp_export.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
index e698508..284bca6 100644
--- a/proxy/src/gp_export.c
+++ b/proxy/src/gp_export.c
@@ -174,8 +174,8 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
uint32_t lifetime;
gss_cred_usage_t cred_usage;
gss_OID_set mechanisms = NULL;
- uint32_t initiator_lifetime;
- uint32_t acceptor_lifetime;
+ uint32_t initiator_lifetime = 0;
+ uint32_t acceptor_lifetime = 0;
struct gssx_cred_element *el;
int ret;
int i, j;
@@ -195,14 +195,14 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
gss_release_name(&ret_min, &name);
name = NULL;
- out->elements.elements_len = mechanisms->count;
- out->elements.elements_val = calloc(out->elements.elements_len,
+ out->elements.elements_val = calloc(mechanisms->count,
sizeof(gssx_cred_element));
if (!out->elements.elements_val) {
ret_maj = GSS_S_FAILURE;
ret_min = ENOMEM;
goto done;
}
+ out->elements.elements_len = mechanisms->count;
for (i = 0, j = 0; i < mechanisms->count; i++, j++) {
@@ -217,14 +217,10 @@ uint32_t gp_export_gssx_cred(uint32_t *min, struct gp_call_ctx *gpcall,
if (ret_maj) {
gp_log_failure(&mechanisms->elements[i], ret_maj, ret_min);
- /* temporarily skip any offender */
+ /* skip any offender */
out->elements.elements_len--;
j--;
continue;
-#if 0
- ret = EINVAL;
- goto done;
-#endif
}
ret_maj = gp_conv_name_to_gssx(&ret_min, name, &el->MN);