(mkt_remove_entry): check if there isn't any entries in the keytab

before removing any since that leads to bad pointer arithmetic and
crashing. From: Wynn Wilkes <wwilkes@vintela.com>.
Make the function return KRB5_KT_NOTFOUND if the entry wasn't in the
keytab (just like the filebased keytab).


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15169 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-05-18 04:44:40 +00:00
parent f97a50a117
commit ed2c4b3694

View File

@@ -133,6 +133,12 @@ mkt_remove_entry(krb5_context context,
{
struct mkt_data *d = id->data;
krb5_keytab_entry *e, *end;
int found = 0;
if (d->num_entries == 0) {
krb5_clear_error_string(context);
return KRB5_KT_NOTFOUND;
}
/* do this backwards to minimize copying */
for(end = d->entries + d->num_entries, e = end - 1; e >= d->entries; e--) {
@@ -143,8 +149,13 @@ mkt_remove_entry(krb5_context context,
memset(end - 1, 0, sizeof(*end));
d->num_entries--;
end--;
found = 1;
}
}
if (!found) {
krb5_clear_error_string (context);
return KRB5_KT_NOTFOUND;
}
e = realloc(d->entries, d->num_entries * sizeof(*d->entries));
if(e != NULL)
d->entries = e;