diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 20:01:46 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-21 20:01:46 +0000 |
commit | 44a09499b4dd3de4910ce3f9a1bc6509e2986b72 (patch) | |
tree | aac4959c9e090a929b380796b34db774ed319d5e | |
parent | 77c3127fd840c608e204eb2c1da7673307d2794b (diff) |
fix the tree comparison function. it turned out that it could fail
with large trees of protocol actions.
-rw-r--r-- | usr.sbin/hoststated/relay.c | 9 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index 2c581edda84..29c9c886f7c 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.62 2007/11/21 14:12:04 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.63 2007/11/21 20:01:45 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -2666,8 +2666,11 @@ relay_load_certfiles(struct relay *rlay) static __inline int relay_proto_cmp(struct protonode *a, struct protonode *b) { - return (strcasecmp(a->key, b->key) + - a->type == b->type ? 0 : (a->type > b->type ? 1 : -1)); + int ret; + ret = strcasecmp(a->key, b->key); + if (ret == 0) + ret = (int)a->type - b->type; + return (ret); } RB_GENERATE(proto_tree, protonode, nodes, relay_proto_cmp); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 2c581edda84..29c9c886f7c 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.62 2007/11/21 14:12:04 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.63 2007/11/21 20:01:45 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -2666,8 +2666,11 @@ relay_load_certfiles(struct relay *rlay) static __inline int relay_proto_cmp(struct protonode *a, struct protonode *b) { - return (strcasecmp(a->key, b->key) + - a->type == b->type ? 0 : (a->type > b->type ? 1 : -1)); + int ret; + ret = strcasecmp(a->key, b->key); + if (ret == 0) + ret = (int)a->type - b->type; + return (ret); } RB_GENERATE(proto_tree, protonode, nodes, relay_proto_cmp); |