add some krb5_{set,clear}_error_string
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9937 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -60,6 +60,7 @@ set_etypes (krb5_context context,
|
||||
etypes = malloc((i+1) * sizeof(*etypes));
|
||||
if (etypes == NULL) {
|
||||
krb5_config_free_strings (etypes_str);
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
for(j = 0, k = 0; j < i; j++) {
|
||||
@@ -172,7 +173,7 @@ krb5_init_context(krb5_context *context)
|
||||
if (config_file == NULL)
|
||||
config_file = krb5_config_file;
|
||||
|
||||
ret = krb5_config_parse_file (config_file, &tmp_cf);
|
||||
ret = krb5_config_parse_file (p, config_file, &tmp_cf);
|
||||
|
||||
if (ret == 0)
|
||||
p->cf = tmp_cf;
|
||||
@@ -214,7 +215,7 @@ krb5_free_context(krb5_context context)
|
||||
*/
|
||||
|
||||
static krb5_error_code
|
||||
default_etypes(krb5_enctype **etype)
|
||||
default_etypes(krb5_context context, krb5_enctype **etype)
|
||||
{
|
||||
krb5_enctype p[] = {
|
||||
ETYPE_DES3_CBC_SHA1,
|
||||
@@ -225,9 +226,12 @@ default_etypes(krb5_enctype **etype)
|
||||
ETYPE_DES_CBC_CRC,
|
||||
ETYPE_NULL
|
||||
};
|
||||
|
||||
*etype = malloc(sizeof(p));
|
||||
if(*etype == NULL)
|
||||
if(*etype == NULL) {
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(*etype, p, sizeof(p));
|
||||
return 0;
|
||||
}
|
||||
@@ -240,14 +244,18 @@ krb5_set_default_in_tkt_etypes(krb5_context context,
|
||||
krb5_enctype *p = NULL;
|
||||
|
||||
if(etypes) {
|
||||
i = 0;
|
||||
while(etypes[i])
|
||||
if(!krb5_enctype_valid(context, etypes[i++]))
|
||||
for (i = 0; etypes[i]; ++i)
|
||||
if(!krb5_enctype_valid(context, etypes[i])) {
|
||||
krb5_set_error_string(context, "enctype %d not supported",
|
||||
etypes[i]);
|
||||
return KRB5_PROG_ETYPE_NOSUPP;
|
||||
}
|
||||
++i;
|
||||
ALLOC(p, i);
|
||||
if(!p)
|
||||
if(!p) {
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memmove(p, etypes, i * sizeof(krb5_enctype));
|
||||
}
|
||||
if(context->etypes)
|
||||
@@ -263,17 +271,22 @@ krb5_get_default_in_tkt_etypes(krb5_context context,
|
||||
{
|
||||
krb5_enctype *p;
|
||||
int i;
|
||||
krb5_error_code ret;
|
||||
|
||||
if(context->etypes) {
|
||||
for(i = 0; context->etypes[i]; i++);
|
||||
++i;
|
||||
ALLOC(p, i);
|
||||
if(!p)
|
||||
if(!p) {
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memmove(p, context->etypes, i * sizeof(krb5_enctype));
|
||||
} else
|
||||
if(default_etypes(&p))
|
||||
return ENOMEM;
|
||||
} else {
|
||||
ret = default_etypes(context, &p);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
*etypes = p;
|
||||
return 0;
|
||||
}
|
||||
@@ -329,8 +342,10 @@ krb5_set_extra_addresses(krb5_context context, const krb5_addresses *addresses)
|
||||
}
|
||||
if(context->extra_addresses == NULL) {
|
||||
context->extra_addresses = malloc(sizeof(*context->extra_addresses));
|
||||
if(context->extra_addresses == NULL)
|
||||
if(context->extra_addresses == NULL) {
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
return krb5_copy_addresses(context, addresses, context->extra_addresses);
|
||||
}
|
||||
|
Reference in New Issue
Block a user