+1998-08-06 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * prof_tree.c (profile_delete_node_relation): Fix bug where
+ deleting a node would corrupt the linked list.
+ (profile_add_node): Fix another linked list corruption
+ problem where an insertion into the middle of the linked
+ list didn't update a previous link. [krb5-libs/615]
+
Mon Mar 2 16:19:58 1998 Ezra Peisach <epeisach@mit.edu>
* Makefile.in: Integrate in the krb5 build tree rules.
if (section->value)
return PROF_ADD_NOT_SECTION;
+ /*
+ * Find the place to insert the new node. We look for the
+ * place *after* the last match of the node name, since
+ * order matters.
+ */
for (p=section->first_child, last = 0; p; last = p, p = p->next) {
cmp = strcmp(p->name, name);
- if (cmp >= 0)
+ if (cmp > 0)
break;
}
retval = profile_create_node(name, value, &new);
return retval;
new->group_level = section->group_level+1;
new->parent = section;
- if (cmp == 0) {
- do {
- last = p;
- p = p->next;
- } while (p && strcmp(p->name, name) == 0);
- }
new->prev = last;
+ new->next = p;
+ if (p)
+ p->prev = new;
if (last)
last->next = new;
else
section->first_child = new;
- if (p)
- new->next = p;
if (ret_node)
*ret_node = new;
return 0;
section->first_child = p->next;
next = p->next;
if (p->next)
- p->next->prev = p;
+ p->next->prev = p->prev;
profile_free_node(p);
p = next;
}