aboutsummaryrefslogtreecommitdiff
path: root/src/util/profile
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1998-08-07 02:03:31 +0000
committerTheodore Tso <tytso@mit.edu>1998-08-07 02:03:31 +0000
commitd2b8a8c59aa918440eb6104525ac261a0c2b403a (patch)
tree2648c9d8d61db14f930f147a1d3c911bcead6dfa /src/util/profile
parentedb1f881c212d3b928987772ed5c77164cbd1589 (diff)
downloadkrb5-d2b8a8c59aa918440eb6104525ac261a0c2b403a.zip
krb5-d2b8a8c59aa918440eb6104525ac261a0c2b403a.tar.gz
krb5-d2b8a8c59aa918440eb6104525ac261a0c2b403a.tar.bz2
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] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10784 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
-rw-r--r--src/util/profile/ChangeLog8
-rw-r--r--src/util/profile/prof_tree.c20
2 files changed, 18 insertions, 10 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog
index c8bc9ce..8addd10 100644
--- a/src/util/profile/ChangeLog
+++ b/src/util/profile/ChangeLog
@@ -1,3 +1,11 @@
+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.
diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c
index 3db7dc6..f4dc975 100644
--- a/src/util/profile/prof_tree.c
+++ b/src/util/profile/prof_tree.c
@@ -145,9 +145,14 @@ errcode_t profile_add_node(section, name, value, ret_node)
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);
@@ -155,19 +160,14 @@ errcode_t profile_add_node(section, name, value, ret_node)
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;
@@ -317,7 +317,7 @@ errcode_t profile_delete_node_relation(section, name)
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;
}