(krb5_cc_register): don't make a copy of the prefix
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10916 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -46,14 +46,11 @@ krb5_cc_register(krb5_context context,
|
|||||||
const krb5_cc_ops *ops,
|
const krb5_cc_ops *ops,
|
||||||
krb5_boolean override)
|
krb5_boolean override)
|
||||||
{
|
{
|
||||||
char *prefix_copy;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < context->num_cc_ops && context->cc_ops[i].prefix; i++) {
|
for(i = 0; i < context->num_cc_ops && context->cc_ops[i].prefix; i++) {
|
||||||
if(strcmp(context->cc_ops[i].prefix, ops->prefix) == 0) {
|
if(strcmp(context->cc_ops[i].prefix, ops->prefix) == 0) {
|
||||||
if(override)
|
if(!override) {
|
||||||
free(context->cc_ops[i].prefix);
|
|
||||||
else {
|
|
||||||
krb5_set_error_string(context,
|
krb5_set_error_string(context,
|
||||||
"ccache type %s already exists",
|
"ccache type %s already exists",
|
||||||
ops->prefix);
|
ops->prefix);
|
||||||
@@ -61,18 +58,12 @@ krb5_cc_register(krb5_context context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefix_copy = strdup(ops->prefix);
|
|
||||||
if (prefix_copy == NULL) {
|
|
||||||
krb5_set_error_string(context, "malloc: out of memory");
|
|
||||||
return KRB5_CC_NOMEM;
|
|
||||||
}
|
|
||||||
if(i == context->num_cc_ops) {
|
if(i == context->num_cc_ops) {
|
||||||
krb5_cc_ops *o = realloc(context->cc_ops,
|
krb5_cc_ops *o = realloc(context->cc_ops,
|
||||||
(context->num_cc_ops + 1) *
|
(context->num_cc_ops + 1) *
|
||||||
sizeof(*context->cc_ops));
|
sizeof(*context->cc_ops));
|
||||||
if(o == NULL) {
|
if(o == NULL) {
|
||||||
krb5_set_error_string(context, "malloc: out of memory");
|
krb5_set_error_string(context, "malloc: out of memory");
|
||||||
free(prefix_copy);
|
|
||||||
return KRB5_CC_NOMEM;
|
return KRB5_CC_NOMEM;
|
||||||
}
|
}
|
||||||
context->num_cc_ops++;
|
context->num_cc_ops++;
|
||||||
@@ -81,7 +72,6 @@ krb5_cc_register(krb5_context context,
|
|||||||
(context->num_cc_ops - i) * sizeof(*context->cc_ops));
|
(context->num_cc_ops - i) * sizeof(*context->cc_ops));
|
||||||
}
|
}
|
||||||
memcpy(&context->cc_ops[i], ops, sizeof(context->cc_ops[i]));
|
memcpy(&context->cc_ops[i], ops, sizeof(context->cc_ops[i]));
|
||||||
context->cc_ops[i].prefix = prefix_copy;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user