[2954] in Kerberos-V5-bugs
Re: krb5-libs/615: bugs with the handling of ->prev in util/profile library
daemon@ATHENA.MIT.EDU (tytso@MIT.EDU)
Thu Aug 6 22:13:07 1998
Date: Thu, 6 Aug 1998 22:05:24 -0400
To: chas@cmf.nrl.navy.mil
Cc: krb5-bugs@MIT.EDU, krb5-unassigned@RT-11.MIT.EDU, kenh@cmf.nrl.navy.mil,
gnats-admin@RT-11.MIT.EDU, krb5-prs@RT-11.MIT.EDU
In-Reply-To: <199807181447.KAA07065@borg.cmf.nrl.navy.mil> (message from Chas
Williams on Sat, 18 Jul 1998 10:47:17 -0400 (EDT))
From: tytso@MIT.EDU
Hi Chas,
Thanks for reporting the bugs on the profile library! I used
a slightly different fix for the profile_add_node() to make the code a
little smaller and cleaner.
- Ted
Index: prof_tree.c
===================================================================
RCS file: /cvs/krbdev/krb5/src/util/profile/prof_tree.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- prof_tree.c 1997/03/25 06:29:54 1.6
+++ prof_tree.c 1998/08/07 02:03:31 1.7
@@ -145,9 +145,14 @@
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 @@
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 @@
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;
}