krb5 commit: Remove inoperative null checks in KDC code
Greg Hudson
ghudson at MIT.EDU
Thu Dec 20 14:29:36 EST 2012
https://github.com/krb5/krb5/commit/41b35299cbfa6a47e93f56344cd2e52dd4418ce6
commit 41b35299cbfa6a47e93f56344cd2e52dd4418ce6
Author: Greg Hudson <ghudson at mit.edu>
Date: Thu Dec 20 14:19:16 2012 -0500
Remove inoperative null checks in KDC code
In prepare_error_tgs, kdc_free_rstate, and kdc_fast_handle_error,
remove unnecessary null checks. The callers avoid passing null
states, and in each case we've already dereferenced the pointer
earlier. Reported by Nickolai Zeldovich <nickolai at csail.mit.edu>.
ticket: 7511
src/kdc/do_tgs_req.c | 6 ++----
src/kdc/fast_util.c | 4 +---
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/kdc/do_tgs_req.c b/src/kdc/do_tgs_req.c
index d41bc5d..1d56566 100644
--- a/src/kdc/do_tgs_req.c
+++ b/src/kdc/do_tgs_req.c
@@ -881,10 +881,8 @@ prepare_error_tgs (struct kdc_request_state *state,
} else
errpkt.e_data = empty_data();
- if (state) {
- retval = kdc_fast_handle_error(kdc_context, state, request, e_data,
- &errpkt, &fast_edata);
- }
+ retval = kdc_fast_handle_error(kdc_context, state, request, e_data,
+ &errpkt, &fast_edata);
if (retval) {
free(scratch);
free(errpkt.text.data);
diff --git a/src/kdc/fast_util.c b/src/kdc/fast_util.c
index 1ce27d6..1dd5f3e 100644
--- a/src/kdc/fast_util.c
+++ b/src/kdc/fast_util.c
@@ -297,8 +297,6 @@ kdc_free_rstate (struct kdc_request_state *s)
{
kdc_realm_t *kdc_active_realm = s->realm_data;
- if (s == NULL)
- return;
if (s->armor_key)
krb5_free_keyblock(kdc_context, s->armor_key);
if (s->strengthen_key)
@@ -418,7 +416,7 @@ kdc_fast_handle_error(krb5_context context,
*fast_edata_out = NULL;
memset(outer_pa, 0, sizeof(outer_pa));
- if (!state || !state->armor_key)
+ if (state->armor_key == NULL)
return 0;
fx_error = *err;
fx_error.e_data.data = NULL;
More information about the cvs-krb5
mailing list