Use krb5_enomem() more consistently in lib/krb5.

This commit is contained in:
Roland C. Dowdeswell
2013-02-13 16:15:00 +08:00
parent edae63418e
commit f0f07ff408
62 changed files with 393 additions and 837 deletions

View File

@@ -119,10 +119,8 @@ add_padata(krb5_context context,
netypes++;
}
pa2 = realloc (md->val, (md->len + netypes) * sizeof(*md->val));
if (pa2 == NULL) {
krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
return ENOMEM;
}
if (pa2 == NULL)
return krb5_enomem(context);
md->val = pa2;
for (i = 0; i < netypes; ++i) {
@@ -166,14 +164,12 @@ init_as_req (krb5_context context,
a->req_body.kdc_options = opts;
a->req_body.cname = malloc(sizeof(*a->req_body.cname));
if (a->req_body.cname == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
a->req_body.sname = malloc(sizeof(*a->req_body.sname));
if (a->req_body.sname == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
ret = _krb5_principal2principalname (a->req_body.cname, creds->client);
@@ -189,8 +185,7 @@ init_as_req (krb5_context context,
if(creds->times.starttime) {
a->req_body.from = malloc(sizeof(*a->req_body.from));
if (a->req_body.from == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
*a->req_body.from = creds->times.starttime;
@@ -202,8 +197,7 @@ init_as_req (krb5_context context,
if(creds->times.renew_till){
a->req_body.rtime = malloc(sizeof(*a->req_body.rtime));
if (a->req_body.rtime == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
*a->req_body.rtime = creds->times.renew_till;
@@ -226,8 +220,7 @@ init_as_req (krb5_context context,
} else {
a->req_body.addresses = malloc(sizeof(*a->req_body.addresses));
if (a->req_body.addresses == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
@@ -251,8 +244,7 @@ init_as_req (krb5_context context,
size_t i;
ALLOC(a->padata, 1);
if(a->padata == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
a->padata->val = NULL;
@@ -290,8 +282,7 @@ init_as_req (krb5_context context,
else if (*ptypes == KRB5_PADATA_ENC_TIMESTAMP) {
ALLOC(a->padata, 1);
if (a->padata == NULL) {
ret = ENOMEM;
krb5_set_error_message(context, ret, N_("malloc: out of memory", ""));
ret = krb5_enomem(context);
goto fail;
}
a->padata->len = 0;