diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-03-12 10:52:35 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-03-12 10:52:35 +0000 |
commit | de2f2f35ddc104a831c2ef44d1ac1b3f19d4a8a5 (patch) | |
tree | 8835df4313f3e37e18c47b65dcb4806bf814171c | |
parent | 1af25862194f2a7cec6c8881c8adb807c4b1e16f (diff) |
Rewrite community_match() for loop. yaya henning@
-rw-r--r-- | usr.sbin/bgpd/rde_attr.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index d6aced91aba..e53252fb157 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.20 2004/03/11 17:12:51 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.21 2004/03/12 10:52:34 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -978,9 +978,12 @@ int community_match(void *data, u_int16_t len, int as, int type) { u_int8_t *p = data; - u_int16_t eas, etype, l; + u_int16_t eas, etype; - for (l = 0; l + 3 < len; len +=4) { + ENSURE((len & 0x3) == 0); + len >>= 2; /* devide by four */ + + for (; len > 0; len--) { eas = *p++; eas <<= 8; eas |= *p++; |