diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-02-09 20:50:10 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-02-09 20:50:10 +0000 |
commit | 3532709880723a2254471eb1076c91cad52201e1 (patch) | |
tree | d259deab4905db4fa22f3b16c86875cd6ccf12d4 /usr.sbin/bgpd/rde_attr.c | |
parent | 26c75d270994c70a5d3ddde49551934ed142ba38 (diff) |
attr_free() should not modify others_len as it does not resize the others
array. It just clears on entry by setting it to NULL and moving that NULL
to the end of the array. With this it will be possible to remove attributes
without readding them right afterwards. Because of this attr_diff() needs to
be more careful because of passed NULL pointers. OK henning@
Diffstat (limited to 'usr.sbin/bgpd/rde_attr.c')
-rw-r--r-- | usr.sbin/bgpd/rde_attr.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index 25144695ab9..3564503c6d0 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.60 2006/01/20 15:34:55 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.61 2006/02/09 20:50:09 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -201,6 +201,10 @@ attr_diff(struct attr *oa, struct attr *ob) { int r; + if (ob == NULL) + return (1); + if (oa == NULL) + return (-1); if (oa->flags > ob->flags) return (1); if (oa->flags < ob->flags) @@ -254,14 +258,13 @@ attr_free(struct rde_aspath *asp, struct attr *attr) for (l = 0; l < asp->others_len; l++) if (asp->others[l] == attr) { attr_put(asp->others[l]); - asp->others[l] = NULL; - --asp->others_len; - for (; l < asp->others_len; l++) - asp->others[l] = asp->others[l + 1]; + for (++l; l < asp->others_len; l++) + asp->others[l - 1] = asp->others[l]; + asp->others[asp->others_len - 1] = NULL; return; } - /* no realloc() others because the slot will be reused soon */ + /* no realloc() because the slot may be reused soon */ } void |