(any_resolve); improving parsing of ANY:
(any_start_seq_get): remove a double free (any_next_entry): iterate over all (sub) keytabs and avoid leave data around to be freed again git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10187 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -60,7 +60,8 @@ any_resolve(krb5_context context, const char *name, krb5_keytab id)
|
|||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
while (strsep_copy(&name, ",", buf, sizeof(buf)) != -1) {
|
while (strsep_copy(&name, ",", buf, sizeof(buf)) != -1
|
||||||
|
&& buf[0] != '\0') {
|
||||||
a = malloc(sizeof(*a));
|
a = malloc(sizeof(*a));
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
@@ -68,7 +69,7 @@ any_resolve(krb5_context context, const char *name, krb5_keytab id)
|
|||||||
}
|
}
|
||||||
if (a0 == NULL) {
|
if (a0 == NULL) {
|
||||||
a0 = a;
|
a0 = a;
|
||||||
a->name = strdup(name);
|
a->name = strdup(buf);
|
||||||
if (a->name == NULL) {
|
if (a->name == NULL) {
|
||||||
krb5_set_error_string(context, "malloc: out of memory");
|
krb5_set_error_string(context, "malloc: out of memory");
|
||||||
ret = ENOMEM;
|
ret = ENOMEM;
|
||||||
@@ -139,11 +140,9 @@ any_start_seq_get(krb5_context context,
|
|||||||
ed->a = a;
|
ed->a = a;
|
||||||
ret = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
|
ret = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
free (ed);
|
|
||||||
free (c->data);
|
free (c->data);
|
||||||
c->data = NULL;
|
c->data = NULL;
|
||||||
krb5_set_error_string (context, "malloc: out of memory");
|
return ret;
|
||||||
return ENOMEM;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -166,14 +165,15 @@ any_next_entry (krb5_context context,
|
|||||||
ret2 = krb5_kt_end_seq_get (context, ed->a->kt, &ed->cursor);
|
ret2 = krb5_kt_end_seq_get (context, ed->a->kt, &ed->cursor);
|
||||||
if (ret2)
|
if (ret2)
|
||||||
return ret2;
|
return ret2;
|
||||||
ed->a = ed->a->next;
|
while ((ed->a = ed->a->next) != NULL) {
|
||||||
|
ret2 = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
|
||||||
|
if (ret2 == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (ed->a == NULL) {
|
if (ed->a == NULL) {
|
||||||
krb5_clear_error_string (context);
|
krb5_clear_error_string (context);
|
||||||
return KRB5_CC_END;
|
return KRB5_CC_END;
|
||||||
}
|
}
|
||||||
ret2 = krb5_kt_start_seq_get(context, ed->a->kt, &ed->cursor);
|
|
||||||
if (ret2)
|
|
||||||
return ret2;
|
|
||||||
} else
|
} else
|
||||||
return ret;
|
return ret;
|
||||||
} while (ret == KRB5_CC_END);
|
} while (ret == KRB5_CC_END);
|
||||||
|
Reference in New Issue
Block a user