diff options
author | Tom Yu <tlyu@mit.edu> | 1998-09-11 16:27:14 +0000 |
---|---|---|
committer | Tom Yu <tlyu@mit.edu> | 1998-09-11 16:27:14 +0000 |
commit | 1a2692776b623f9e45bacb522c9369865a6cde7e (patch) | |
tree | ca50a30515adf726aff58138ce4210f6441ea04b | |
parent | b5f2e95ec48bbf0f29261dbc6bc0457884c12d11 (diff) | |
download | krb5-1a2692776b623f9e45bacb522c9369865a6cde7e.zip krb5-1a2692776b623f9e45bacb522c9369865a6cde7e.tar.gz krb5-1a2692776b623f9e45bacb522c9369865a6cde7e.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]
[pullup from trunk]
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/V1_0_BRANCH@10917 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/util/profile/ChangeLog | 8 | ||||
-rw-r--r-- | src/util/profile/prof_tree.c | 20 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index b12b2e9..3e61d02 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] + Fri Jan 23 20:55:06 1998 Theodore Ts'o <tytso@rsts-11.mit.edu> * prof_parse.c (parse_std_line, parse_quoted_string, diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index a192e1d..24b447e 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; } |