svn rev #25422: trunk/src/kdc/
ghudson@MIT.EDU
ghudson at MIT.EDU
Fri Oct 28 12:18:45 EDT 2011
http://mv.ezproxy.com.ezproxyberklee.flo.org/fisheye/changelog/krb5/?cs=25422
Commit By: ghudson
Log Message:
Use zero-filled states for all async ops in KDC
There have been a couple of uninitialized field bugs in the
restructured KDC code, partly because compilers can't find these bugs
as easily as they can find uninitialized local variable bugs. Use
zero-filled state structures to make this type of bug less likely.
Changed Files:
U trunk/src/kdc/dispatch.c
U trunk/src/kdc/do_as_req.c
U trunk/src/kdc/kdc_preauth.c
Modified: trunk/src/kdc/dispatch.c
===================================================================
--- trunk/src/kdc/dispatch.c 2011-10-28 15:59:54 UTC (rev 25421)
+++ trunk/src/kdc/dispatch.c 2011-10-28 16:18:45 UTC (rev 25422)
@@ -90,9 +90,9 @@
krb5_data *response = NULL;
struct dispatch_state *state;
- state = malloc(sizeof(*state));
- if (!state) {
- (*respond)(arg, ENOMEM, NULL);
+ state = k5alloc(sizeof(*state), &retval);
+ if (state == NULL) {
+ (*respond)(arg, retval, NULL);
return;
}
state->respond = respond;
Modified: trunk/src/kdc/do_as_req.c
===================================================================
--- trunk/src/kdc/do_as_req.c 2011-10-28 15:59:54 UTC (rev 25421)
+++ trunk/src/kdc/do_as_req.c 2011-10-28 16:18:45 UTC (rev 25422)
@@ -460,35 +460,16 @@
krb5_enctype useenctype;
struct as_req_state *state;
- state = malloc(sizeof(*state));
- if (!state) {
- (*respond)(arg, ENOMEM, NULL);
+ state = k5alloc(sizeof(*state), &errcode);
+ if (state == NULL) {
+ (*respond)(arg, errcode, NULL);
return;
}
- state->session_key.contents = 0;
- state->enc_tkt_reply.authorization_data = NULL;
- state->reply.padata = 0;
- memset(&state->reply, 0, sizeof(state->reply));
state->respond = respond;
state->arg = arg;
- state->ticket_reply.enc_part.ciphertext.data = 0;
- state->server_keyblock.contents = NULL;
- state->client_keyblock.contents = NULL;
- state->reply_encpart.enc_padata = 0;
- state->client = NULL;
- state->server = NULL;
state->request = request;
- state->e_data = NULL;
- state->typed_e_data = FALSE;
- state->authtime = 0;
- state->c_flags = 0;
state->req_pkt = req_pkt;
- state->rstate = NULL;
- state->sname = 0;
- state->cname = 0;
- state->pa_context = NULL;
state->from = from;
- memset(&state->rock, 0, sizeof(state->rock));
#if APPLE_PKINIT
asReqDebug("process_as_req top realm %s name %s\n",
Modified: trunk/src/kdc/kdc_preauth.c
===================================================================
--- trunk/src/kdc/kdc_preauth.c 2011-10-28 15:59:54 UTC (rev 25421)
+++ trunk/src/kdc/kdc_preauth.c 2011-10-28 16:18:45 UTC (rev 25422)
@@ -847,8 +847,8 @@
*e_data_out = NULL;
/* Allocate our state. */
- state = malloc(sizeof(*state));
- if (!state) {
+ state = calloc(1, sizeof(*state));
+ if (state == NULL) {
(*respond)(arg);
return;
}
@@ -1168,12 +1168,11 @@
return;
}
- state = malloc(sizeof(*state));
- if (!state) {
+ state = calloc(1, sizeof(*state));
+ if (state == NULL) {
(*respond)(arg, ENOMEM);
return;
}
- memset(state, 0, sizeof(*state));
state->respond = respond;
state->arg = arg;
state->context = context;
More information about the cvs-krb5
mailing list